Use shift key with scene.actionmanager

Hi!

Recently I’ve been trying to port my DOM keydown events to the babylon.js action manager. Playground: https://www.babylonjs-playground.com/#E8C51D#27

Playground lines 241-262 are the new keydown functions with the action manager, and playground lines 261-318 are the DOM events. With the DOM events using keycodes, I can use the shift key. With the action manager, I’m not sure how. (I’m surprised that the space key works! check out line 245!)

Any help appreciated!

Givo

Hi,

check line 238 : https://www.babylonjs-playground.com/#E8C51D#28

scene.actionManager.registerAction(new BABYLON.ExecuteCodeAction(BABYLON.ActionManager.OnKeyDownTrigger, function (evt) {
    console.log(evt);
    if(evt.sourceEvent.shiftKey) {
        alert("shift key pressed");
    }
}));

evt.sourceEvent returns a KeyboardEvent - Web APIs | MDN

Thanks a lot!

I’m used to DOM events.

Givo