mirror of
https://github.com/fergalmoran/ladybird.git
synced 2026-01-04 15:45:25 +00: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:
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user