LibWeb/EventHandler: Ignore repeated keyup events

Platforms such as X11 will typically send repeated keyRelease/keyup
events as a result of auto-repeating:

  * KeyPress (initial)
  * KeyRelease (repeat)
  * KeyPress (repeat)
  * KeyRelease (repeat)
  * ad infinitum

Make our EventHandler more spec-compliant by ignoring all repeated keyup
events. This fixes long-pressing the arrow keys on
https://playbiolab.com/.
This commit is contained in:
Jelle Raaijmakers 2024-10-22 15:35:00 +02:00 committed by Tim Flynn
parent 9309cc9df3
commit 77850b3540
Notes: github-actions[bot] 2024-10-22 15:21:30 +00:00

View file

@ -1171,8 +1171,13 @@ EventResult EventHandler::handle_keydown(UIEvents::KeyCode key, u32 modifiers, u
return EventResult::Accepted;
}
EventResult EventHandler::handle_keyup(UIEvents::KeyCode key, u32 modifiers, u32 code_point, [[maybe_unused]] bool repeat)
EventResult EventHandler::handle_keyup(UIEvents::KeyCode key, u32 modifiers, u32 code_point, bool repeat)
{
// Keyup events as a result of auto-repeat are not fired.
// See: https://w3c.github.io/uievents/#events-keyboard-event-order
if (repeat)
return EventResult::Dropped;
return fire_keyboard_event(UIEvents::EventNames::keyup, m_navigable, key, modifiers, code_point, false);
}