From ac19e538572410a3753c9cf77200b07e7317ba69 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AE=87=E5=A4=A9?= Date: Tue, 3 Nov 2020 18:05:23 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E6=88=90Readme?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 14 ++++++++++++++ src/index.es7 | 6 +++++- 2 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 package.json 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) {