The physical key pressed, ignoring the user's locale - may be unavailable (e.g. IE11 gives us no way to get at real physical codes.)
You'd only want to potentially use this for e.g. binding "WASD" game controls in a way that maintains the physical keyboard layout, even if the end user toggles between Qwerty and Dvorak layouts. Use with caution.
The logical key pressed, respecting the user's locale.
true
if this is a repeat keydown event caused by holding the key down for an extended duration, false
if this
is a newly pressed key.
KeyboardEvent already provides repeat
, but this lies on IE11 (it's false
for some repeat keydown events).
Generated using TypeDoc
mmk.keyboard
automatically extendsKeyboardEvent
with new fields. Most of them correspond to existing fields. Since some of these fields are immutable (at least on some browsers), we're unable to fix them in-place, and instead create alternatives prefixed withmmk...
- it's also possible you don't want to break third party libraries that do their own code/key/repeat corrections internally.If you register your own events with
addEventListener("keydown", function(e) { ... }, true);
beforemmk.keyboard.js
is loaded, it's possible these fields won't be populated. An easy workaround is to simply loadmmk.keyboard.js
first.See also: KeyboardEvent (MDN web docs)