fix keybinds

This commit is contained in:
MeexReay 2025-05-24 20:25:44 +03:00
parent 7c76fa25ed
commit 655d83aa5f

View File

@ -65,27 +65,31 @@ function moveWindowToTop(wid) {
window.mxwm_windows = windows window.mxwm_windows = windows
} }
let altKey = false let pressedKeys = []
let shiftKey = false
let ctrlKey = false function isPressed(key) {
return pressedKeys.indexOf(key) !== -1
}
async function onKeyDown(ctx, key) { async function onKeyDown(ctx, key) {
if (key == "Control") ctrlKey = true if (pressedKeys.indexOf(key) === -1) {
if (key == "Alt") altKey = true pressedKeys.push(key)
if (key == "Shift") shiftKey = true }
if (altKey && shiftKey && key == "Q") { console.log(pressedKeys)
if ((isPressed("Alt") || isPressed("Meta")) && isPressed("Shift") && isPressed("Q")) {
disableGraphics() disableGraphics()
return return
} }
if (altKey && shiftKey && key == "C") { if ((isPressed("Alt") || isPressed("Meta")) && isPressed("Shift") && isPressed("C")) {
signalWindow(selected_window, 9) signalWindow(selected_window, 9)
closeWindow(selected_window) closeWindow(selected_window)
return return
} }
if (altKey && key == "Enter") { if ((isPressed("Alt") || isPressed("Meta")) && pressedKeys.indexOf("Enter") !== -1) {
executeCommand(["/app/zterm.js"]) executeCommand(["/app/zterm.js"])
return return
} }
@ -94,9 +98,12 @@ async function onKeyDown(ctx, key) {
} }
async function onKeyUp(ctx, key) { async function onKeyUp(ctx, key) {
if (key == "Control") ctrlKey = false let index = pressedKeys.indexOf(key)
if (key == "Alt") altKey = false if (index !== -1) {
if (key == "Shift") shiftKey = false pressedKeys.splice(index, 1)
}
console.log(pressedKeys)
if (selected_window != null) getWindow(selected_window).onkeyup(key) if (selected_window != null) getWindow(selected_window).onkeyup(key)
} }