LibWeb: Re-assign cmd+arrow key events to home/end keys on macOS

In text documents, pressing the left/right arrow keys with the cmd key
pressed should be treated as home/end key presses.
This commit is contained in:
Timothy Flynn 2024-09-05 12:43:07 -04:00 committed by Andreas Kling
parent a0072f422a
commit bf9d05d97a
Notes: github-actions[bot] 2024-09-06 05:43:52 +00:00

View File

@ -929,6 +929,19 @@ bool EventHandler::handle_keydown(UIEvents::KeyCode key, u32 modifiers, u32 code
return true;
}
#if defined(AK_OS_MACOS)
if ((modifiers & UIEvents::Mod_Super) != 0) {
if (key == UIEvents::KeyCode::Key_Left) {
key = UIEvents::KeyCode::Key_Home;
modifiers &= ~UIEvents::Mod_Super;
}
if (key == UIEvents::KeyCode::Key_Right) {
key = UIEvents::KeyCode::Key_End;
modifiers &= ~UIEvents::Mod_Super;
}
}
#endif
if (key == UIEvents::KeyCode::Key_Left || key == UIEvents::KeyCode::Key_Right) {
auto increment_or_decrement_cursor = [&]() {
if ((modifiers & UIEvents::Mod_PlatformWordJump) == 0) {