fix: Certain shortcuts not being captured by ImHex Web
This commit is contained in:
parent
9b12232e9f
commit
6ead8d8b49
4
dist/web/source/wasm-config.js
vendored
4
dist/web/source/wasm-config.js
vendored
@ -262,3 +262,7 @@ function js_resizeCanvas() {
|
|||||||
canvas.width = Math.min(document.documentElement.clientWidth, window.innerWidth || 0);
|
canvas.width = Math.min(document.documentElement.clientWidth, window.innerWidth || 0);
|
||||||
canvas.height = Math.min(document.documentElement.clientHeight, window.innerHeight || 0);
|
canvas.height = Math.min(document.documentElement.clientHeight, window.innerHeight || 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Prevent default browser shortcuts from preventing ImHex ones to work
|
||||||
|
document.addEventListener('keydown', e => { e.preventDefault(); })
|
||||||
|
document.addEventListener('keyup', e => { e.preventDefault(); })
|
@ -890,6 +890,7 @@ namespace hex {
|
|||||||
glfwSetKeyCallback(m_window, [](GLFWwindow *window, int key, int scanCode, int action, int mods) {
|
glfwSetKeyCallback(m_window, [](GLFWwindow *window, int key, int scanCode, int action, int mods) {
|
||||||
std::ignore = mods;
|
std::ignore = mods;
|
||||||
|
|
||||||
|
#if !defined(OS_WEB)
|
||||||
// Handle A-Z keys using their ASCII value instead of the keycode
|
// Handle A-Z keys using their ASCII value instead of the keycode
|
||||||
if (key >= GLFW_KEY_A && key <= GLFW_KEY_Z) {
|
if (key >= GLFW_KEY_A && key <= GLFW_KEY_Z) {
|
||||||
std::string_view name = glfwGetKeyName(key, scanCode);
|
std::string_view name = glfwGetKeyName(key, scanCode);
|
||||||
@ -904,6 +905,9 @@ namespace hex {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
// Emscripten doesn't support glfwGetKeyName. Just pass the value through.
|
||||||
|
#endif
|
||||||
|
|
||||||
if (key == GLFW_KEY_UNKNOWN) return;
|
if (key == GLFW_KEY_UNKNOWN) return;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user