mirror of
https://github.com/SerenityOS/serenity.git
synced 2025-01-22 09:21:57 -05:00
Ladybird/Qt: Map Enter keypresses to the code point '\n'
Previously, on systems where pressing Enter would generate "\r\n", only the '\r' character was being sent to the event handler. This change ensures consistent behavior across platforms regardless of their native line ending characters.
This commit is contained in:
parent
5a8e82e6ea
commit
8320faf052
1 changed files with 7 additions and 1 deletions
|
@ -451,10 +451,16 @@ void WebContentView::keyPressEvent(QKeyEvent* event)
|
|||
return;
|
||||
}
|
||||
|
||||
auto modifiers = get_modifiers_from_qt_keyboard_event(*event);
|
||||
if (event->key() == Qt::Key_Enter || event->key() == Qt::Key_Return) {
|
||||
// This ensures consistent behavior between systems that treat Enter as '\n' and '\r\n'
|
||||
client().async_key_down(m_client_state.page_index, KeyCode::Key_Return, modifiers, '\n');
|
||||
return;
|
||||
}
|
||||
|
||||
auto text = event->text();
|
||||
auto point = text.isEmpty() ? 0u : event->text()[0].unicode();
|
||||
auto keycode = get_keycode_from_qt_keyboard_event(*event);
|
||||
auto modifiers = get_modifiers_from_qt_keyboard_event(*event);
|
||||
client().async_key_down(m_client_state.page_index, keycode, modifiers, point);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue