[SOLVED] Issue in pressing KEY_SPACE and MOUSEBUTTON_LEFT simultaneously

While I’m playing with key input and mouse input, I noticed one unexpected behavior.
https://playcanvas.com/project/373369/overview/simultaneous-press-test

In test.js, I created these simple key and mouse input code with console.log().

    // Called every frame, dt is time in seconds since last update
    update: function (dt) {
        if (app.keyboard.isPressed(pc.KEY_SPACE) === true) {
            console.log("SPACE is pressed");
        }
        if (app.mouse.isPressed(pc.MOUSEBUTTON_LEFT) === true) {
            console.log("MOUSELEFT is pressed");
        }
    }

When I press KEY_SPACE then MOUSEBUTTON_LEFT, the log for the mouse button doesn’t fire. Right after the symptom, even after I release space key, mouse button log doesn’t fire for around 0.5 sec.

When I press MOUSEBUTTON_LEFT then KEY_SPACE, both logs fire reciprocally. I tried with mouse event handler. But it seemed the key down event doesn’t fire either while KEY_SPACE is pressed.

I think this is an unexpected behavior of the engine. What is the cause? FYI, I’m using the latest Chrome on Windows.

I just tried pressing Space and LMB one after other, or holding one or the other in different sequences, and seem not seeing any strange delays/behaviours.

Just as clue, are you testing mouse on touch-friendly device?

Do all browsers show same behaviour?
And what if you make keyboard and mouse input using vanillajs window.addEventListener('keydown', .. and similar functionality, does it shows same symptoms?

I experienced this issue with my PC + touch pad. Today I checked with my other device (PC) and there isn’t any problem even with touch pad. I think the issue is specific to my device and it’s not PlayCanvas issue.

Thanks!

1 Like