Emit custom events from an input so you can do stuff like listening for "enter" and "esc" events the same way as you would "keyup".
Takes an element, usually an
<textarea> and registers a
keyup handler on it that emits named events for special keys. It does
esc events by default.
You can override the events by passing an optional second argument that follows the format:
npm install add-keyup-events
var addKeyupEvents = ;// some inputvar input = document;// pass it our input;// Now we can listen for "enter" and "esc" events using the// normal `addEventListener` the browser gives us.input;
You can also override the events to listen for whatever you want.
// some inputvar input = document;// create a custom hash of keycode to event name mappings:var customEvents =65: 'a'12: 'enter';// pass it our input, and our custom events;// now we can listen for 'a' events and 'enter' eventsinput;