aboutsummaryrefslogtreecommitdiff
path: root/src/background/keys.js
diff options
context:
space:
mode:
authorShin'ya Ueoka <ueokande@i-beam.org>2017-08-13 12:00:39 +0900
committerShin'ya Ueoka <ueokande@i-beam.org>2017-08-13 12:00:39 +0900
commit082450928a35ea8d35fdbcd176dbd972e45acfec (patch)
tree5973294649d322b1dc6edd2bbb07658aa499fab3 /src/background/keys.js
parente7342e9c237e1deea69ed66e07b7f79cd534056e (diff)
use key-queue for input
Diffstat (limited to 'src/background/keys.js')
-rw-r--r--src/background/keys.js21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/background/keys.js b/src/background/keys.js
new file mode 100644
index 0000000..d6a94fb
--- /dev/null
+++ b/src/background/keys.js
@@ -0,0 +1,21 @@
+const keyEquals = (key1, key2) => {
+ return (key1.code === key2.code) &&
+ ((key1.shift || false) === (key2.shift || false)) &&
+ ((key1.ctrl || false) === (key2.ctrl || false)) &&
+ ((key1.alt || false) === (key2.alt || false)) &&
+ ((key1.meta || false) === (key2.meta || false));
+};
+
+const keysEquals = (keys1, keys2) => {
+ if (keys1.length !== keys2.length) {
+ return false;
+ }
+ for (let i = 0; i < keys1.length; ++i) {
+ if (!keyEquals(keys1[i], keys2[i])) {
+ return false;
+ }
+ }
+ return true;
+}
+
+export { keyEquals, keysEquals };