Add getAllKeyCodes method to API (#439)

pull/441/head
Lokesh Pathrabe 2 years ago committed by GitHub
parent 3d5b789986
commit 7a8e2b2e4b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -31,6 +31,21 @@ function getPressedKeyString() {
return _downKeys.map((c) => getKey(c) || getModifier(c) || String.fromCharCode(c)); return _downKeys.map((c) => getKey(c) || getModifier(c) || String.fromCharCode(c));
} }
function getAllKeyCodes() {
return []
.concat(...Object.values(_handlers))
.map(({ key, scope, mods, shortcut }) => {
return {
scope,
shortcut,
mods,
keys: key.split('+').map((k) => {
return code(k);
}),
};
});
}
// 表单控件控件判断 返回 Boolean // 表单控件控件判断 返回 Boolean
// hotkey is effective only when filter return true // hotkey is effective only when filter return true
function filter(event) { function filter(event) {
@ -414,6 +429,7 @@ const _api = {
getScope, getScope,
deleteScope, deleteScope,
getPressedKeyCodes, getPressedKeyCodes,
getAllKeyCodes,
isPressed, isPressed,
filter, filter,
trigger, trigger,

Loading…
Cancel
Save