You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
-`string`: representing the keyboard key to listen to
18
-
-`Array<string>`: representing any of keys to listen to
17
+
-`string`: representing the keyboard key or code to listen to (e.g. `'a'` or `'KeyA'`)
18
+
-`Array<string>`: representing any of keys or codes to listen to (e.g. `['a', 'KeyA']`)
19
19
-`Function`: custom filter function to validate event key
20
20
-`true`: to listen for all events
21
21
22
-
See [KeyboardEvent.key Value column](https://developer.mozilla.org/en-US/docs/Web/API/UI_Events/Keyboard_event_key_values) for possible values
22
+
See [KeyboardEvent.key Value column](https://developer.mozilla.org/en-US/docs/Web/API/UI_Events/Keyboard_event_key_values) and [KeyboardEvent.code Value columns](https://developer.mozilla.org/en-US/docs/Web/API/UI_Events/Keyboard_event_code_values) for possible values.
23
+
Try to use `KeyboardEvent.code` instead of `KeyboardEvent.key` when possible, as it works more reliable across different keyboard layouts (e.g. Latin / Cyrillic).
24
+
Codes are still layout-dependent, so try to avoid using codes that can be located in different places on the keyboard, like `QWERTZ` or `AZERTY` layouts.
25
+
23
26
-`callback`: a function to be called when the key is pressed. Before called, it will be checked whether keyboard shortcuts are disabled, or interactive element is currently focused, or whether options should be applied
24
27
-`options`: options to be applied to the shortcut:
25
28
-`push`: whether the event should be triggered on both keydown and keyup (default: `false`)
0 commit comments