Skip to content

Implement keyboard.show for html5 - #1537

Open
RblSb wants to merge 2 commits into
Kode:mainfrom
RblSb:html5-virt-keyboard
Open

RblSb wants to merge 2 commits into
Kode:mainfrom
RblSb:html5-virt-keyboard

Conversation

@RblSb

@RblSb RblSb commented Jul 26, 2026 •

Copy link
Copy Markdown
Contributor

keyboard.show() now creates hidden focused input html element to show virtual keyboard, resends keydown/up events to game canvas and generates direct keypress events when input value updated.

Closes #1257

@RblSb
RblSb force-pushed the html5-virt-keyboard branch from 714edc9 to a20a9e2 Compare September 2, 2026 00:00
@RblSb

RblSb commented Sep 19, 2026

Copy link
Copy Markdown
Contributor Author

@RobDangerous i just found another reason why this PR is nice, it fixes keypress events with disabled system interventions:

Keyboard.disableSystemInterventions(Full);
Keyboard.get().notify(null, null, char -> trace(char)); // not working right now

For example, i would like to prevent default Space key from scrolling page in some browsers, but then you cannot type spaces into canvas text inputs.

I did too much verbose changes as always, so i can cleanup it to make diff more readable for review if you want.

@RobDangerous

Copy link
Copy Markdown
Member

That would be nice, cleanups can go into a separate PR.

@RblSb
RblSb force-pushed the html5-virt-keyboard branch from a20a9e2 to 304656e Compare September 20, 2026 02:01
@RblSb

RblSb commented Sep 20, 2026

Copy link
Copy Markdown
Contributor Author

Since there is no way to prevent page scroll on Space / some other shortcuts like /, without disabling keypress at all, i decided to use keydown for both events. But i just found that Ctrl-C will generate c char now, so i also added isPrintableText, that will check for modifiers and don't generate chars when meta/ctrl/alt is active, except when AltGr chars are typed.

KeyboardImpl is still just:

keyboard.show() now creates hidden focused input html element to show virtual keyboard, resends keydown/up events to game canvas and generates direct keypress events when input value updated.

And onBlur/onFocus ifs are needed to prevent System.background/foreground callbacks when this input element will change focus on keyboard.show/hide.

This branch has not been deployed

No deployments
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.

Handle .show()/.hide() of the virtual keyboard on mobile devices with HTML5 target

2 participants