diff --git a/package.json b/package.json new file mode 100644 index 0000000..cfeb38a --- /dev/null +++ b/package.json @@ -0,0 +1,14 @@ +{ + "name": "@bytedo/keyboard", + "version": "1.0.0", + "description": "支持各种按钮组合。原生js开发, 无任何依赖(不到2KB)。使用也非常简单。", + "main": "dist/index.js", + "repository": { + "type": "git", + "url": "git+https://github.com/bytedo/keyboard.git" + }, + "keywords": ["keyboard", "hotkey", "shortcut", "yutent"], + "author": "yutent", + "license": "MIT", + "dependencies": {} +} diff --git a/src/index.es7 b/src/index.es7 index 15e4b7d..2ef8629 100644 --- a/src/index.es7 +++ b/src/index.es7 @@ -28,7 +28,11 @@ function hide(target, name, value) { function check(ev) { var checked = false - checked = ev.keyCode === this.keys.key + if (typeof this.keys.key === 'object') { + checked = this.keys.key.includes(ev.keyCode) + } else { + checked = ev.keyCode === this.keys.key + } if (checked) { for (let k of this.keys) {