LibWeb: Implement up/down arrow navigation in textarea

This commit is contained in:
mikiubo 2025-05-10 09:46:09 +02:00 committed by Tim Flynn
commit 23aadc02ca
Notes: github-actions[bot] 2025-08-15 10:33:20 +00:00
6 changed files with 111 additions and 0 deletions

View file

@ -1321,6 +1321,16 @@ EventResult EventHandler::handle_keydown(UIEvents::KeyCode key, u32 modifiers, u
return EventResult::Handled;
}
if (key == UIEvents::KeyCode::Key_Up || key == UIEvents::KeyCode::Key_Down) {
auto collapse = modifiers & UIEvents::Mod_Shift ? InputEventsTarget::CollapseSelection::No : InputEventsTarget::CollapseSelection::Yes;
if (key == UIEvents::KeyCode::Key_Up) {
target->decrement_cursor_position_to_previous_line(collapse);
} else {
target->increment_cursor_position_to_next_line(collapse);
}
return EventResult::Handled;
}
if (key == UIEvents::KeyCode::Key_Home) {
auto collapse = modifiers & UIEvents::Mod_Shift ? InputEventsTarget::CollapseSelection::No : InputEventsTarget::CollapseSelection::Yes;
target->move_cursor_to_start(collapse);