Hi Jules,
On linux, when a key is pressed for some time, the keyStateChanged / keyPressed callbacks are called repeatedly with a sequence “keyrelease/keypress” . On mac and windows, when a key is kept pressed, only “keypress” events happen. Here is a small patch that allows filtering the spurious keyrelease events of the linux version, in case you are interested, in juce_linux_Windowing.cpp :
[code]+ static bool keyReleaseMsgShouldBeIgnored(const XKeyEvent* keyReleaseEvent) {
-
if (XPending(display)) {
-
XEvent e;
-
XPeekEvent(display, &e);
-
// same timestamp + same keycode + keypress => this is an auto-repeat keyRelease/keyPress pair !
-
if ((e.type == 2 /* KeyPress */) &&
-
(e.xkey.keycode == keyReleaseEvent->keycode) &&
-
(e.xkey.time == keyReleaseEvent->time)) {
-
return true;
-
}
-
}
-
return false;
- }
- void handleKeyReleaseEvent (const XKeyEvent* const keyEvent)
{ -
if (keyReleaseMsgShouldBeIgnored(keyEvent)) return;
[/code]