Skip to content

ohos: Better keyboard support - #47359

Merged
Narfinger merged 1 commit into
servo:mainfrom
jschwe:jschwender/keyboard-support
Aug 19, 2026
Merged

Narfinger merged 1 commit into
servo:mainfrom
jschwe:jschwender/keyboard-support

Conversation

@jschwe

@jschwe jschwe commented Aug 19, 2026

Copy link
Copy Markdown
Member

For physical keyboards we need to translate the OH KeyEventCode into a KeyEvent with a Unicode character, taking into account keyboard state (like shift or caps lock).
Since OH still doesn't have a keyboard layout API, this is greatly simplified due to only needing to support US keyboard layout. The actual conversion is handled in the xcomponent-sys crate.

This now allows typing with a real (US-layout) keyboard to work as expected on OpenHarmony.

Testing: This is not covered by any automatic tests, and I also didn't find an API that allows simulating raw keyboard events (hdc shell uinput seems to behave differently to a raw keyboard). This was manually tested on a dayu-200 developer board with a keyboard attached.

For physical keyboards we need to translate the OH KeyEventCode
into a KeyEvent with a Unicode character, taking into account
keyboard state (like shift or caps lock).
Since OH still doesn't have a keyboard layout API, this is
greatly simplified due to only needing to support US keyboard layout.
The actual conversion is handled in the xcomponent-sys crate.

This now allows typing with a real keyboard to work as expected.
(Limited testing)

Signed-off-by: Jonathan Schwender <schwenderjonathan@gmail.com>
@servo-highfive servo-highfive added the S-awaiting-review There is new code that needs to be reviewed. label Aug 19, 2026
@jschwe
jschwe requested a review from Narfinger August 19, 2026 12:34
Comment thread ports/servoshell/egl/ohos/mod.rs Resolved
@servo-highfive servo-highfive added S-needs-code-changes Changes have not yet been made that were requested by a reviewer. and removed S-awaiting-review There is new code that needs to be reviewed. labels Aug 19, 2026
@Narfinger
Narfinger added this pull request to the merge queue Aug 19, 2026
@servo-highfive servo-highfive added S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. and removed S-needs-code-changes Changes have not yet been made that were requested by a reviewer. labels Aug 19, 2026
Merged via the queue into servo:main with commit c1517a9 Aug 19, 2026
39 checks passed
@servo-highfive servo-highfive removed the S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. label Aug 19, 2026
RichardTjokroutomo pushed a commit to RichardTjokroutomo/servo that referenced this pull request Oct 6, 2026
For physical keyboards we need to translate the OH KeyEventCode into a
KeyEvent with a Unicode character, taking into account keyboard state
(like shift or caps lock).
Since OH still doesn't have a keyboard layout API, this is greatly
simplified due to only needing to support US keyboard layout. The actual
conversion is handled in the xcomponent-sys crate.

This now allows typing with a real (US-layout) keyboard to work as
expected on OpenHarmony.

Testing: This is not covered by any automatic tests, and I also didn't
find an API that allows simulating raw keyboard events (`hdc shell
uinput` seems to behave differently to a raw keyboard). This was
manually tested on a dayu-200 developer board with a keyboard attached.

Signed-off-by: Jonathan Schwender <schwenderjonathan@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants