|
|
|
@ -1,4 +1,4 @@ |
|
|
|
|
const keyEquals = (key1, key2) => { |
|
|
|
|
const identifyKey = (key1, key2) => { |
|
|
|
|
return (key1.code === key2.code) && |
|
|
|
|
((key1.shift || false) === (key2.shift || false)) && |
|
|
|
|
((key1.ctrl || false) === (key2.ctrl || false)) && |
|
|
|
@ -6,16 +6,23 @@ const keyEquals = (key1, key2) => { |
|
|
|
|
((key1.meta || false) === (key2.meta || false)); |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
const keysEquals = (keys1, keys2) => { |
|
|
|
|
if (keys1.length !== keys2.length) { |
|
|
|
|
const hasPrefix = (keys, prefix) => { |
|
|
|
|
if (keys.length < prefix.length) { |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
for (let i = 0; i < keys1.length; ++i) { |
|
|
|
|
if (!keyEquals(keys1[i], keys2[i])) { |
|
|
|
|
for (let i = 0; i < keys.length; ++i) { |
|
|
|
|
if (!identifyKey(keys[i], prefix[i])) { |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
export { keyEquals, keysEquals }; |
|
|
|
|
const identifyKeys = (keys1, keys2) => { |
|
|
|
|
if (keys1.length !== keys2.length) { |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
return hasPrefix(keys1, keys2); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
export { identifyKey, identifyKeys, hasPrefix }; |
|
|
|
|