Skip to content
This repository has been archived by the owner on Apr 4, 2019. It is now read-only.

Latest commit

 

History

History
51 lines (30 loc) · 848 Bytes

Readme.md

File metadata and controls

51 lines (30 loc) · 848 Bytes

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