You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Apr 4, 2019. It is now read-only.
super keyword is command on mac and ctrl on anything else.
gmail like sequences (a b c *)
key combos
nice simple api
you can unbind anything you bind
Example
vark=require('k')(window);// combosk('command + shift + enter',fn);// on OSX `super` will be replaced with `command`// on other operating systems it will be replaced with `ctrl`.k('super + k',fn);// sequencesk('a b c',fn);k('* b c',fn);k('super + shift + a b c',fn);
API
k(el)
Create a new keyboard dispatcher on the given element
k(keys, fn)
Bind the given fn on keys.
.el
the element k is listening on.
#bind
Bind keys with fn(e).
#unbind
Unbind all listeners of keys,
unbind fn with keys,
unbind all listeners on all keys.
k.unbind();// => unbind all listenersk.unbind('enter');// => unbind all enter listenersk.unbind('command + enter');// => unbind all `command + enter` listenersk.unbind('command + enter',fn);// => unbind `fn` just from `command + enter`
#destroy
Removes all listeners on k.el.
Removes all k.listeners.
#ignore
this function is called just before any handlers are called,
if it returns true no handlers will be called for this event.
by default it returns true for input, textarea or select.
if you still want k to handle inputs you can k.ignore = false.
.shift
true if shiftKey is down.
.ctrl
true if ctrlKey is down.
.alt
true if alt is down.
.command
true if command is down.
.modifiers
null if no modifiers are down, otherwise it's true.