kibo.js 处理键盘事件的Javascript工具库

< ![CDATA[

这个也是做在线编辑用到的

选中文字快捷键.提高编辑效率

https://github.com/marquete/kibo

 

用法很简单

Examples

var k = new Kibo();

Single or multiple key combinations

k.down(['up', 'down'], function() {
  console.log('up or down arrow key pressed');
}).up('tab', function() {
  console.log('TAB key released');
});

Key combinations with modifiers

function handler() {
  console.log('last key: ' + k.lastKey());
}

k.down(['shift q', 'ctrl alt x'], handler);

Wildcards

k.down(['any letter', 'any number'], function() {
  console.log('letter or number key pressed');
  console.log('shift key was' + (k.lastKey('shift') ? '' : ' not') + ' pressed');
});

k.up('any', function() {
  console.log('key released');
});

Preventing the default action

k.down('f5', function() { return false; });
]]>

你可能感兴趣的:(JavaScript)