Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SAPP_EVENT_CHAR for Space is fired when Ctrl+Space is pressed. #1079

Open
skejeton opened this issue Jul 12, 2024 · 2 comments
Open

SAPP_EVENT_CHAR for Space is fired when Ctrl+Space is pressed. #1079

skejeton opened this issue Jul 12, 2024 · 2 comments

Comments

@skejeton
Copy link
Contributor

OS: Windows. Only occurs for Ctrl+Space, other control combinations block the input as expected.

@floooh
Copy link
Owner

floooh commented Jul 12, 2024

Hmm, I guess the CHAR behaviour on Ctrl isn't really standardized between platforms, for instance on macOS, Ctrl plus a character key seems to fire a CHAR event with the ASCII control character code (for instance Ctrl-C fires a CHAR event with character code 3, while Ctrl-Space fires a CHAR event with character code 0.

On Linux, Ctrl-Space fires a CHAR event with char code 0x20 (32 dec), Ctrl-C fires nothing, and Ctrl with other characters fires a CHAR event with the regular ASCII/UNICODE code.

Windows is different again as you're seeing.

The behaviour isn't even consistent in web browsers, e.g. Chrome behaves differently between macOS and Windows.

TBH I'm hesitant to change the behaviour, sokol-app currently simply forwards whatever char event it gets from the operating system without trying to have a consistent behaviour for 'edge cases' (and it looks like not even web browsers do this).

One quick workaround on your side would be to check the sapp_event.modifiers field and ignore any char events that have the SAPP_MODIFIER_CTRL, SAPP_MODIFIER_SUPER or SAPP_MODIFIER_ALT bits set.

@skejeton
Copy link
Contributor Author

Yeah.. This is a much broader issue, probably even better solved by a separate layer between sokol to translate the character events in a consistent platform agnostic way.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants