← #83 Copy screenshots to the clipboard on macOS

Add keyboard shortcuts

Topics: HTML

By using the accesskey attribute, we can specify a shortcut key for the user to activate or focus on an element. The value of the attribute has to be a single character.

It's worth noting that each browser provides a different combination of keys to access the shortcut.

Chromealt + ctrl + keyalt + keyalt + key
Firefoxalt + ctrl + keyalt + shift + keyalt + shift + key
Safarialt + ctrl + keyn/an/a

In the following sample code, pressing the combination alt + ctrl + e on Chrome macOS will trigger the button's click event.

<button accesskey="e" onclick="alert('Edit')">Edit</button>
Fix a typo or suggest an improvement
#85 Number headings and subheadings automatically