summaryrefslogtreecommitdiff
path: root/wwwroot/js/keyboard.js
diff options
context:
space:
mode:
Diffstat (limited to 'wwwroot/js/keyboard.js')
-rw-r--r--wwwroot/js/keyboard.js18
1 files changed, 18 insertions, 0 deletions
diff --git a/wwwroot/js/keyboard.js b/wwwroot/js/keyboard.js
new file mode 100644
index 0000000..9d06b75
--- /dev/null
+++ b/wwwroot/js/keyboard.js
@@ -0,0 +1,18 @@
+async function keyDownHandler(e) {
+ e.preventDefault();
+
+ var element = Array.from(document.querySelectorAll('div.dialog'))
+ .filter(e => e.style.visibility == 'visible')
+ .map(e => ({ element: e, zIndex: parseInt(e.style.zIndex) }))
+ .sort((a, b) => b.zIndex - a.zIndex)
+ .map(e => e.element)[0];
+
+ if(element) {
+ await window.dialogObjects
+ .find(d => d.element == element)
+ .dialogObject
+ .invokeMethodAsync('KeyHandler', e.key);
+ }
+}
+
+window.onload = () => document.onkeydown = keyDownHandler; \ No newline at end of file