KeyCode Constants
A minimal javascript package with Key Code constants.
Installation
$ npm install keycode-js --save
Usage
Include the package using common js require()
:
var KeyCode = require('keycode-js');
Or, using <script>
tags:
<script type="text/javascript" src="/path/to/keycode-js/dist/keycode.min.js"></script>
Here you go:
window.addEventListener('keyup', function(e) {
if (e.keyCode === KeyCode.KEY_RETURN) {
console.log('It was the Return key.');
} else {
console.log('It was any other key.');
}
});