Skip to content


Subversion checkout URL

You can clone with
Download ZIP
A micro-micro library for querying modifier keys at any time.
branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
bower.json add bower.json
modifiers.min.js create interface for adding additional keys
package.json update for npm

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 (modifiers.command || modifiers.control) {
  // do something special

// ..inside your click handler
if (modifiers.shift) {

You can also add your own to the defaults:

  leftArrow: 37,
  upArrow: 38,
  rightArrow: 39,
  downArrow: 40,
  w: 87,
  a: 65,
  s: 83,
  d: 68


To create the minified and compressed version with source mapping, run:

uglifyjs modifiers.js --source-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.



Something went wrong with that request. Please try again.