Skip to content

[rcore][web] Add EmscriptenKeyboardCallback() to consume key events #4956

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

Merged
merged 1 commit into from
Jul 30, 2025

Conversation

Moros1138
Copy link
Contributor

There are times when we want to use keys that are otherwise used for browser functions.

F1 -> opens a help tab (in Chromium based browsers, see #4951)
F5 -> refresh the page

There are many more key/key combinations that trigger browser actions. This PR seeks prevent the default browser actions by consuming all keyboard events. This leaves us free to use any keyboard cominations as we would in any other environment.

This PR fixes issue #4951

@raysan5 raysan5 changed the title [rcore] [web] add EmscriptenKeyboardCallback to consume key events [rcore][web] Add EmscriptenKeyboardCallback() to consume key events May 29, 2025
@raysan5 raysan5 added the platform: Web Web platform label May 29, 2025
@raysan5 raysan5 merged commit 18ae6a3 into raysan5:master Jul 30, 2025
@raysan5
Copy link
Owner

raysan5 commented Jul 30, 2025

@Moros1138 I'm merging this change but I'm not fully convinced if this is the best/expected behaviour or the fact of consuming keys on raylib side could affect other systems... let's see...

@Moros1138
Copy link
Contributor Author

@raysan5 sorry for the delayed response.

I don't think it's unreasonable for a raylib user to expect their web builds to function the same way as it does on their windows builds.

Google Docs, Google Sheets, Youtube, Vimeo, Tiktok, X, Snapchat, Monaco Editor, Github Workspaces, and CodeMirror just to name a few off the top of my head that all override/consume keyboard events.

I realize "other projects do it" isn't a complete argument. I do hope these points serve to boost your confidence in your decision!

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

Successfully merging this pull request may close these issues.

2 participants