Update hiddenInput

insertCompositionText returns it's entire contents instead of just the new data, so we have to slice(-1)
This commit is contained in:
FlamedDogo99 2024-06-08 22:49:56 -06:00
parent 6f88bc4dfb
commit 75413f5045

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 3.0.5-chat-fix // @version 3.0.6-chat-fix
// @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==
@ -375,7 +375,7 @@ function insertCanvasElements() {
hiddenInput.style.cssText = "position:absolute;top: 0vh; margin: auto; left: 8vh; right:0vh; width: 8vh; height: 8vh;font-size:20px;z-index:-10;color: transparent;text-shadow: 0 0 0 black;"; hiddenInput.style.cssText = "position:absolute;top: 0vh; margin: auto; left: 8vh; right:0vh; width: 8vh; height: 8vh;font-size:20px;z-index:-10;color: transparent;text-shadow: 0 0 0 black;";
hiddenInput.value = " " //Allows delete to be detected before input is changed hiddenInput.value = " " //Allows delete to be detected before input is changed
hiddenInput.addEventListener("input", function(e) { hiddenInput.addEventListener("input", function(e) {
let inputData = e.data ?? "delete"; // backspace makes null let inputData = (e.data == null) ? "delete" : e.data.slice(-1); // backspace makes null
window.lastKey = inputData window.lastKey = inputData
hiddenInput.value = " "; // We need a character to detect deleting hiddenInput.value = " "; // We need a character to detect deleting
if(window.keyboardFix) { if(window.keyboardFix) {