shortcuts-component

0.2.1 • Public • Published

shortcuts

keyboard shortcuts, similiar to component/events.

Installation

$ component install yields/shortcuts

Example

 
function Editable(el){
  this.shortcuts = shortcuts(el, this);
  this.shortcuts.bind('command + z', 'undo');
  this.shortcuts.bind('command + b', 'bold');
}
 
Editable.prototype.undo = function(e){};
Editable.prototype.bold = function(e){};
 

API

Shortcuts

Bind shortcuts on the given el with obj.

.k

k instance

#bind

Bind keys with method

#unbind

Unbind all events, or keys or keys with method.

shortcuts.unbind('command + z', 'undo') // => unbind `undo`, `command + z`
shortcuts.unbind('command + z'); // => unbind `command + z`
shortcuts.unbind(); // => unbind all

License

MIT

Readme

Keywords

none

Package Sidebar

Install

npm i shortcuts-component

Weekly Downloads

1

Version

0.2.1

License

none

Last publish

Collaborators

  • yields