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.

(cherry picked from commit bf9d05d97a570e8d4ebd83ca7e757938c2b504b3)
This commit is contained in:
Timothy Flynn authored and Nico Weber committed 2024-11-26 16:03:32 -05:00
1 parent 5bc052948a
commit 071d85e1cc
1 file changed
+13
@@ -951,6 +951,19 @@ EventResult EventHandler::handle_keydown(UIEvents::KeyCode key, u32 modifiers, u
return EventResult::Handled;
}
#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) {