angular-keydown
Angular service for keydown detection
Sometimes, it could be useful to detect a pressed key during a click or another event. Let's say you have a validation button. It would rock if it pops up a confirmation message when you click on it, but not if you hold the shift key, right ?
Angular-keydown makes it really easy!
Demos & usage
http://msieurtoph.github.io/angular-keydown
Installation
npm i angular-keydown --save
Usage
Please, visit http://msieurtoph.github.io/angular-keydown for live examples.
angular ;
Hold shift key and click me
The service lets you know whether the following keys are pressed :
shift
,ctrl
,alt
up
,down
,right
,left
arrowspgUp
,pgDown
space
,escape
,enter
,tab
For other keys you can look to Keydown.others[_theKeyCode_]
For instance, Keydown.others[65]
will equal true
if the a
key is down.
Keydown.pressed
gives you the list of pressed keys.
For instance, if a
, b
and c
keys are down, Keydown.pressed
will equal [65, 66, 67]