/

HTML / CSS / JavaScript Tutorial

HTML Standard attribute: accesskey

[this page | pdf | back links]

The HTML accesskey attribute indicates the shortcut key used to activate / focus an element. In HTML 5 it can in principle be used with any element, although in practice it may not be of much use with some elements. Different browsers use different ways of accessing shortcut keys (sometimes using the Alt key (or Alt and Shift keys simultaneously) or the Control key, in combination with a specified character.

 

Valid attribute values (when used with <form> elements) include:

 

Value

Description

character

The shortcut key character used to activate / focus the element

 

EXAMPLE:


HTML USED IN THIS EXAMPLE:
<!DOCTYPE html>
<html> <!-- Copyright (c) Nematrian Limited 2018 -->
<head></head>
<body>
Set using HTML:<br>
<input type="text" accesskey="f" value="accesskey: f">

<br><br>Set using JavaScript:<br>
<input id="x1" type="text" value="accesskey: g">

<script>
document.getElementById("x1").accessKey = "g";
</script>

</body>
</html>


NAVIGATION LINKS
Contents | Prev | Next | HTML Attributes


Desktop view | Switch to Mobile