Added new mooncore js dependencies. Added ace editor build
This commit is contained in:
25
Moonlight.Client/wwwroot/js/keyBinds.js
Normal file
25
Moonlight.Client/wwwroot/js/keyBinds.js
Normal file
@@ -0,0 +1,25 @@
|
||||
window.moonCoreKeyBinds = {
|
||||
storage: {},
|
||||
|
||||
registerHotkey: function (key, modifier, action, dotNetObjRef) {
|
||||
|
||||
const hotkeyListener = async (event) => {
|
||||
if (event.code === key && (!modifier || event[modifier + 'Key'])) {
|
||||
event.preventDefault();
|
||||
|
||||
await dotNetObjRef.invokeMethodAsync("OnHotkeyPressed", action);
|
||||
}
|
||||
};
|
||||
|
||||
this.storage[`${key}${modifier}`] = hotkeyListener;
|
||||
window.addEventListener('keydown', hotkeyListener);
|
||||
},
|
||||
|
||||
unregisterHotkey: function (key, modifier) {
|
||||
const listenerKey = `${key}${modifier}`;
|
||||
if (this.storage[listenerKey]) {
|
||||
window.removeEventListener('keydown', this.storage[listenerKey]);
|
||||
delete this.storage[listenerKey];
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user