Skip to content

Native shift + right click on non-canvas makes shift stuck for the viewer #1980

@NiklasPor

Description

@NiklasPor

Describe the bug
When you right-click outside of the canvas with xeokit while pressing the shift, the browser context menu will open. Once you're going back into the canvas, all controls will behave like shift is still pressed, even though you let go of it while pressing the context menu.

Fix: In the following code, keyboard button status is only updated if keyup is fired. keyup never fires, if the users hits shift and then opens the context menu via right click (then the contextmenu event fires).

this._keyboardEventsElement.addEventListener("keyup", this._keyUpListener = (e) => {
if (!this.enabled || (!this.keyboardEnabled)) {
return;
}
if (e.target.tagName !== "INPUT" && e.target.tagName !== "TEXTAREA") {
if (e.keyCode === this.KEY_CTRL) {
this.ctrlDown = false;
} else if (e.keyCode === this.KEY_ALT) {
this.altDown = false;
} else if (e.keyCode === this.KEY_SHIFT) {
this.shiftDown = false;
}
this.keyDown[e.keyCode] = false;
this.fire("keyup", e.keyCode, true);
}
});

To Reproduce

  1. Go to https://jsfiddle.net/o6Lzvu58/2/
  2. Click on shift + right click in the right area to open the context menu
  3. Let go of shift
  4. Close the context menu
  5. Now the viewer still behaves like shift is pressed
  6. Once you hit shift again on your keyboard everything will work again
Screen.Recording.2025-11-05.at.12.19.08.mov

Desktop (please complete the following information):

  • MacOS
  • Chrome

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions