![dependabot[bot]](/assets/img/avatar_default.png)
* Commit updated Javascript packages * Bump preact from 10.5.4 to 10.5.5 in /build/javascript (#265) * Trying a new github workflow to install javascript packages * Bump tailwindcss from 1.9.2 to 1.9.4 in /build/javascript (#266) Bumps [tailwindcss](https://github.com/tailwindlabs/tailwindcss) from 1.9.2 to 1.9.4. - [Release notes](https://github.com/tailwindlabs/tailwindcss/releases) - [Changelog](https://github.com/tailwindlabs/tailwindcss/blob/master/CHANGELOG.md) - [Commits](https://github.com/tailwindlabs/tailwindcss/compare/v1.9.2...v1.9.4) Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Commit updated Javascript packages * Bump preact from 10.5.4 to 10.5.5 in /build/javascript Bumps [preact](https://github.com/preactjs/preact) from 10.5.4 to 10.5.5. - [Release notes](https://github.com/preactjs/preact/releases) - [Commits](https://github.com/preactjs/preact/compare/10.5.4...10.5.5) Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: Gabe Kangas <gabek@real-ity.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Owncast <owncast@owncast.online> * Bump @justinribeiro/lite-youtube in /build/javascript Bumps [@justinribeiro/lite-youtube](https://github.com/justinribeiro/lite-youtube) from 0.9.0 to 0.9.1. - [Release notes](https://github.com/justinribeiro/lite-youtube/releases) - [Commits](https://github.com/justinribeiro/lite-youtube/commits) Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: Owncast <owncast@owncast.online> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Gabe Kangas <gabek@real-ity.com>
keycode
Simple map of keyboard codes.
Installation
npm
$ npm install keycode
component
$ component install timoxley/keycode
Example
var keycode = require('keycode');
document.addEventListener('keydown', function(e) {
console.log("You pressed", keycode(e))
})
API
keycode
tries to make an intelligent guess as to what
you're trying to discover based on the type of argument
you supply.
keycode(keycode:Event)
Returns the name of the key associated with this event.
document.body.addEventListener('keyup', function(e) {
console.log(keycode(e)) // prints name of key
})
Due to the keypress event being weird,keycode
currently does not support the keypress
event, but this should not be an issue as keydown
and keyup
work perfectly fine.
keycode(keycode:Number)
Returns the lowercase name of a given numeric keycode.
keycode(13) // => 'enter'
keycode(name:String)
Returns the numeric keycode for given key name.
keycode('Enter') // => 13
// keycode is not case sensitive
keycode('eNtEr') // => 13
Name Aliases
Common aliases are also supplied:
> for (var alias in keycode.aliases) { console.log(alias, keycode(keycode(alias))) }
ctl ctrl
pause pause/break
break pause/break
caps caps lock
escape esc
pgup page up
pgdn page down
ins insert
del delete
spc space
keycode.isEventKey(event: Event, nameOrCode: String | Number)
Tests if an keyboard event against a given name or keycode.
Will return true
if the event matches the given name or keycode, false
otherwise.
// assume event is an keydown event with key 'enter'
keycode.isEventKey(event, 'enter') // => true
keycode.isEventKey(event, 'down') // => false
keycode.isEventKey(event, 13) // => true
keycode.isEventKey(event, 40) // => false
Maps
Key code/name maps are available directly as keycode.codes
and keycode.names
respectively.
keycode.names[13] // => 'enter'
keycode.codes['Enter'] // => 13
Credit
project : keycode
repo age : 3 years, 8 months
active : 29 days
commits : 66
files : 13
authors :
49 Tim Oxley 74.3%
4 jkroso 6.1%
3 Amir Abu Shareb 4.5%
1 Greg Reimer 1.5%
1 Kenan Yildirim 1.5%
1 Abel Toledano 1.5%
1 Sam 1.5%
1 TJ Holowaychuk 1.5%
1 Yoshua Wuyts 1.5%
1 Nathan Zadoks 1.5%
1 Brenton Simpson 1.5%
1 Brian Noguchi 1.5%
1 Gilad Peleg 1.5%
Original key mappings lifted from http://jsfiddle.net/vWx8V/ via http://stackoverflow.com/questions/5603195/full-list-of-javascript-keycodes