Skip to content

Commit

Permalink
update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
jaywcjlove committed May 23, 2015
1 parent 3a57000 commit 7cbbae7
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,20 @@ Run `bower info hotkeysjs` to list the available versions.

```js
// 定义a快捷键
hotkeys('a', function(){ alert('你按下了 a!') });
hotkeys('a', function(event){
//event.srcElement: input
//event.target: input
if(event.target === "input"){
alert('你在输入框中按下了 a!')
}
alert('你按下了 a!')
});

// 返回false将停止活动,并阻止默认浏览器事件
hotkeys('ctrl+r', function(){ alert('停止刷新!'); return false });

// 多个快捷方式做同样的事情
hotkeys('⌘+r, ctrl+r', function(){ });

```


Expand Down Expand Up @@ -90,6 +96,16 @@ hotkeys('command+ctrl+shift+a,f', function(){
```


## 过滤
`INPUT` `SELECT` `TEXTAREA` 默认不处理。
`key.filter` 返回 `true` 快捷键设置才会起作用,`flase` 快捷键设置失效。

```javascript
key.filter = function(event){
return true;
}
```

## 兼容模式

```js
Expand Down

0 comments on commit 7cbbae7

Please sign in to comment.