Modifier key queries
Inspired by keymaster. This is a small subset of the functionality in that library. See for yourself how small it is.
At any point in time you can query the modifiers
object to see if a modifier key is held down.
Default supported keys are:
shift
, alt
, option
(same as alt
), control
, command
if modifierscommand || modifierscontrol // do something special // ..inside your click handlerif modifiersshift ...
You can also add your own to the defaults:
modifiers
Building
To create the minified and compressed version with source mapping, run:
uglifyjs modifiers.js --source-map modifiers.min.map --screw-ie8 -c -m -o modifiers.min.js
The code uses addEventListener so if you sadly need to support IE8 you'll want to change the code to use something like what's described here.
License
MIT