Skip to content

[core] Mod-tap key presses not registered properly (PRESS-RELEASE in single frame) #2827

@dmlary

Description

@dmlary

Please, before submitting a new issue verify and check:

  • I tested it on latest raylib version from master branch
  • I checked there is no similar issue already reported
  • My code has no errors or misuse of raylib

Issue description

Very fast key presses not registering in IsKeyPressed(), but do show up in GetKeyPressed().

I've tracked this issue down to using a keyboard with QMK firmware, using mod-tap. When tapping the spacebar, I get both the KeyDown & KeyUp event in the same frame. This key pressed event isn't registered when I check IsKeyPressed(), but does show up when I call GetKeyPressed().

It exhibits most clearly when trying to play the Pang game on the raylib website: https://www.raylib.com/games/classics/loader.html?name=classic_pang

Environment

This happens both natively and for the raylib web-based demos.

  • Platforms: Web & Desktop
  • OS: OSX 11.7
  • OpenGL:
INFO: GL: OpenGL device information:
INFO:     > Vendor:   ATI Technologies Inc.
INFO:     > Renderer: AMD Radeon Pro 5500M OpenGL Engine
INFO:     > Version:  4.1 ATI-4.6.21
INFO:     > GLSL:     4.10

Issue Screenshot

Screen Shot 2022-12-11 at 7 12 00 PM

Screenshot of logging messages for code snippet below.

Top part of the log is me hitting space on laptop keyboard, bottom is me hitting space on external keyboard running QMK firmware and mod-tap on spacebar.

Code Example

minimal code logging discrepancy between IsKeyPressed() and GetKeyPressed():

                PollInputEvents();
                if (IsKeyPressed(KEY_SPACE)) {
                    log_debug("space pressed");
                }
                for (int k = GetKeyPressed(); k != 0; k = GetKeyPressed()) {
                    log_debug("pressed {}", k);
                }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions