summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjak1 <mike.wollmann@gmail.com>2021-08-01 22:46:21 +0200
committerjak1 <mike.wollmann@gmail.com>2021-08-01 22:46:21 +0200
commit19779e744cc24457503483f6b171b32b3110f3b5 (patch)
treebd216b6f187a365cdc6d79fad45fba6812ffaa9c
parent38563b1baa146285f86d20c8de0c39c1d1c1710d (diff)
downloadthepixelworld-19779e744cc24457503483f6b171b32b3110f3b5.tar.gz
thepixelworld-19779e744cc24457503483f6b171b32b3110f3b5.tar.bz2
thepixelworld-19779e744cc24457503483f6b171b32b3110f3b5.tar.xz
thepixelworld-19779e744cc24457503483f6b171b32b3110f3b5.zip
added focus to ui and game element
-rw-r--r--client/index.html8
1 files changed, 6 insertions, 2 deletions
diff --git a/client/index.html b/client/index.html
index de444a8..797628f 100644
--- a/client/index.html
+++ b/client/index.html
@@ -392,7 +392,9 @@
document.onkeydown = function(event){
//console.log(event.keyCode);
- if (document.activeElement === document.getElementById('ctx')){
+ if (document.activeElement === document.getElementById('ui') ||
+ document.activeElement === document.getElementById('game') ||
+ document.activeElement === document.getElementById('ctx')){
if(event.keyCode === 68 || event.keyCode === 39) // d
socket.emit('keyPress',{inputId: 'right', state: true});
else if(event.keyCode === 65 || event.keyCode === 37) // a
@@ -416,7 +418,9 @@
}
document.onmousedown = function(event){
- if (document.activeElement === document.getElementById('ctx')){
+ if (document.activeElement === document.getElementById('ui') ||
+ document.activeElement === document.getElementById('game') ||
+ document.activeElement === document.getElementById('ctx')){
socket.emit('keyPress',{inputId: 'attack', state: true});
}
}