Moved keyboardFix event listener

This commit is contained in:
FlamedDogo99 2024-06-06 15:56:10 -06:00 committed by GitHub
parent 1da82869d4
commit 69f8dedef5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -6,7 +6,7 @@
// @downloadURL https://raw.githubusercontent.com/FlamedDogo99/EaglerMobile/main/eaglermobile.user.js // @downloadURL https://raw.githubusercontent.com/FlamedDogo99/EaglerMobile/main/eaglermobile.user.js
// @license Apache License 2.0 - http://www.apache.org/licenses/ // @license Apache License 2.0 - http://www.apache.org/licenses/
// @match https://eaglercraft.com/mc/* // @match https://eaglercraft.com/mc/*
// @version 2.16 // @version 2.17
// @updateURL https://raw.githubusercontent.com/FlamedDogo99/EaglerMobile/main/eaglermobile.user.js // @updateURL https://raw.githubusercontent.com/FlamedDogo99/EaglerMobile/main/eaglermobile.user.js
// @run-at document-start // @run-at document-start
// ==/UserScript== // ==/UserScript==
@ -60,13 +60,6 @@ Event.prototype.preventDefault = function() {
this._preventDefault(); this._preventDefault();
} }
} }
window.addEventListener("keydown", function(e) {
if((e.key == null || e.keyCode == null || e.which == null) && !window.keyboardFix) {
window.keyboardFix = true;
keyEvent(window.lastKey, "keydown")
keyEvent(window.lastKey, "keyup")
}
}, false);
// Key and mouse events // Key and mouse events
// Note: the client must have the key, keyCode, and which parameters defined or it will crash // Note: the client must have the key, keyCode, and which parameters defined or it will crash
// Note: for text inputs, the client only reads from the "key" paramater // Note: for text inputs, the client only reads from the "key" paramater
@ -394,6 +387,13 @@ function insertCanvasElements() {
} }
} }
}, false); }, false);
hiddenInput.addEventListener("keydown", function(e) {
if((e.key == null || e.keyCode == null || e.which == null) && !window.keyboardFix) {
window.keyboardFix = true;
keyEvent(window.lastKey, "keydown")
keyEvent(window.lastKey, "keyup")
}
}, false);
document.body.appendChild(hiddenInput); document.body.appendChild(hiddenInput);
let keyboardButton = createTouchButton("keyboardButton", "inMenu"); let keyboardButton = createTouchButton("keyboardButton", "inMenu");
keyboardButton.style.cssText = "top: 0vh; margin: auto; left: 8vh; right:0vh; width: 8vh; height: 8vh;" keyboardButton.style.cssText = "top: 0vh; margin: auto; left: 8vh; right:0vh; width: 8vh; height: 8vh;"