Skip to content

[rcore][web] Pressing F1 opens a help tab in certain chromium based browsers #4951

Open
@Moros1138

Description

@Moros1138

Issue description

In Microsoft Edge and Google Chrome I have noticed pressing F1 opens a help tab.

Repoduce in the affected browsers by following these steps:

  1. Visit: https://www.raylib.com/examples/shapes/loader.html?name=shapes_top_down_lights
  2. click anywhere in the running example to ensure it has focus
  3. Press 'F1' key
  4. See the problem.

I assume, given the pattern involves Chromium based browsers that this is true of other similarly based browsers. Firefox was unaffected.

Environment

Windows 11
Microsoft Edge Version 136.0.3240.76 (Official build) (64-bit)
Google Chrome Version 136.0.7103.114 (Official Build) (64-bit)

Possible Solution

I fixed this locally in my own build adding the following to my shell:

        document.addEventListener('keydown', function(event)
        {
            if (event.key == 'F1' || event.keyCode == 112)
                event.preventDefault();
        });

this could easily be integrated into the web platform code like so:

EM_ASM({
        document.addEventListener('keydown', function(event)
        {
            if (event.key == 'F1' || event.keyCode == 112)
                event.preventDefault();
        });
});

Probably somewhere in InitPlatform.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions