HTML global attribute accesskey

The accesskey attribute sets one or more keyboard shortcuts that will select the element.

accesskey attributes are added to three input elements.

This enables users to use keyboard shortcuts to move between used elements.

The key combination required to trigger the accesskey setting differs between platforms.

For Windows, it is the Alt key and the accesskey value pressed together.

  • press Alt+n to focus on the first input element and enter my name.
  • press Alt+p to focus on the second input element and enter my password.
  • press Alt+s to focus on Log In button, which submits the form.


<element accesskey="character">

Attribute Values

shortcut key to activate the element

Browser compatibility

accesskey Yes Yes Yes Yes Yes


The following code uses accesskey attribute in a simple form.

            Name: <input type="text"  name="name" accesskey="n"/>
            Password: <input  type="password" name="password"  accesskey="p"/>
            <input type="submit" value="Log  In"  accesskey="s"/>
</html><!-- w ww  .  j a v  a 2 s.c o m-->

Click to view the demo