This modules handles low-level keyboard events and normalize them across browsers.
delegateKeyboardEvents(textarea: HTMLElement, handlers: [string]:any)privatestatic
Setup to capture the keyboard events from a
TextArea and redispatch them to
In general, commands (arrows, delete, etc..) should be handled
keystroke() handler while text input should be handled in
TextArea element that will capture the keyboard
events. While this element will usually be a
TextArea, it could be any
element that is focusable and can receive keyboard events.
invoked on a key down event, including for special keys such as ESC, arrow keys, tab, etc... and their variants with modifiers.
invoked on a keypress or other events
when a key corresponding to a character has been pressed. This include
This does not include arrow keys, tab, etc... but does include 'space'
When a 'character' key is pressed, both
be invoked. When a control/function key is pressed, only
be invoked. In some cases, for example when using input methods or entering
typedtext() will be invoked.
Invoked in response to a paste command. Not all browsers support this (Chrome doesn't), so typedtext() will be invoked instead.
Create a normalized string representation of the key combo, i.e., key code and modifier keys. For example:
- To Do:
- See https://github.com/madrobby/keymaster/blob/master/keymaster.js
- Doesn't work very well for command-
- Returns "Alt-Alt" when only the Alt key is pressed
- See https://github.com/madrobby/keymaster/blob/master/keymaster.js - Doesn't work very well for command-