Jump to content

Trigger parameters for special keys?


croustibat
 Share

Recommended Posts

Hi everybody,

I need to know what is the parameter for creating a trigger on special key such as Escape:

scene.actionManager.registerAction(new BABYLON.ExecuteCodeAction({ trigger: BABYLON.ActionManager.OnKeyUpTrigger, parameter: "Escape" },    function () {      console.log("heya");}));

And if there is a documentation on that I could not find it, sorry  :(

EDIT: of course the code above does not work!

Link to comment
Share on other sites

Hello this is the code used to check the key:

var unicode = evt.sourceEvent.charCode ? evt.sourceEvent.charCode : evt.sourceEvent.keyCode;var actualkey = String.fromCharCode(unicode).toLowerCase();if (actualkey !== parameter.toLowerCase()) {    continue;}

I'm afraid that this will not work with escape

 

can you provide a playground repro? I'll try to make it work :)

Link to comment
Share on other sites

Thanks deltaKosh, but it's impossible to reproduce my app with the playground :)

Anyway I just managed to do what I wanted, but I'm not sure if the keyCode value is implemented in all browsers, plus, it's very difficult to read

scene.actionManager.registerAction(new BABYLON.ExecuteCodeAction(BABYLON.ActionManager.OnKeyUpTrigger,  function (evt) {    if(evt.sourceEvent.keyCode === 27) {      console.log("do something!");    }}));

Thanks again!

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...