Disable on-screen keyboard when smartphone is detected #14

This commit is contained in:
ChaoticByte 2023-02-13 19:47:00 +01:00
parent 0ab45c6e68
commit 548af757e7

View file

@ -41,8 +41,12 @@
"{bksp} . ," "{bksp} . ,"
] ]
} }
// Check if on smartphone
let onSmartphone = navigator.userAgent.toLowerCase().match(/android|webos|iphone|ipod|blackberry/i) != null;
console.log(onSmartphone)
// Configure keyboard when all DOM content has loaded // Configure keyboard when all DOM content has loaded
document.addEventListener("DOMContentLoaded", () => { document.addEventListener("DOMContentLoaded", () => {
if (!onSmartphone) {
// Get element to send input to // Get element to send input to
let keyboardInputElement = document.querySelector(".keyboard-input"); let keyboardInputElement = document.querySelector(".keyboard-input");
// Get language code // Get language code
@ -61,10 +65,10 @@
} }
// determine if the numeric class has to be added // determine if the numeric class has to be added
if (layoutCode == "numeric") { if (layoutCode == "numeric") {
theme = "hg-theme-default darkTheme numeric" theme = "hg-theme-default darkTheme numeric";
} }
else { else {
theme = "hg-theme-default darkTheme" theme = "hg-theme-default darkTheme";
} }
// virtual keyboard // virtual keyboard
const Keyboard = window.SimpleKeyboard.default; const Keyboard = window.SimpleKeyboard.default;
@ -77,6 +81,6 @@
keyboardInputElement.value = input; keyboardInputElement.value = input;
} }
}); });
}
}); });
})() })()