Skip to content

Commit

Permalink
KeyBind: Fix multiple key presses triggered from one long press
Browse files Browse the repository at this point in the history
  • Loading branch information
camnwalter committed Dec 28, 2023
1 parent 06d43ed commit 6b1f288
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/main/kotlin/com/chattriggers/ctjs/api/client/KeyBind.kt
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ class KeyBind {
}

internal fun onTick() {
if (isPressed()) {
if (isPressed() && !down) {
if (keyBinding in customKeyBindings) {
while (keyBinding.wasPressed()) {
// consume the key press if not built-in keybinding
Expand All @@ -113,6 +113,10 @@ class KeyBind {
}

if (down && !isKeyDown()) {
while (keyBinding.wasPressed()) {
// consume the rest of the key presses
}

onKeyRelease?.trigger(arrayOf())
down = false
}
Expand Down

0 comments on commit 6b1f288

Please sign in to comment.