Keyvent.js Save

Keyboard events simulator

Project README


Keyboard events simulator.

Build Status


Simulate 'keydown' events on the 'document' element:

keyvent.down(13); // You can use key codes...
keyvent.down('enter'); // ... a few alias...
keyvent.down('shift a'); // ... combination of keys...
keyvent.down('⇧ a'); // ... and some sugar!

The same is valid for simulating 'keyup' events:

keyvent.up('shift a');
keyvent.up('⇧ a');

If you want to simulate keyboard events on other DOM elements, you have to set a new context (please note that the 'on' function takes a raw DOM element as parameter):

var headerDiv = document.getElementById('headerDiv');

You may want to keep a copy of this context to use later:

var headerDivKeyboard = keyvent.on(headerDiv);

The following aliases are supported (borrowed from , shift, option, , alt, ctrl, control, command, , backspace, tab, clear, enter, return, esc, escape, space, up, down, left, right, home, end, pageup, pagedown, del, delete, and f1 through f19.


  • The initial intent of this lib is to support testing, but you can find a better usage for it. :-)
  • If you are using AMD (e.g. require.js) this lib becomes a module. Otherwise it'll create a global keyvent.

Browser Compatibility

I've ran the tests in Chrome and Firefox. If you find any incompatibility or want to support other browsers, please do a pull request with the fix! :-)


This is licensed under the feel-free-to-do-whatever-you-want-to-do license.

Open Source Agenda is not affiliated with "Keyvent.js" Project. README Source: gtramontina/keyvent.js
Open Issues
Last Commit
9 years ago

Open Source Agenda Badge

Open Source Agenda Rating