croustibat Posted September 8, 2015 Share Posted September 8, 2015 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! Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted September 8, 2015 Share Posted September 8, 2015 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 Quote Link to comment Share on other sites More sharing options...
croustibat Posted September 8, 2015 Author Share Posted September 8, 2015 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 readscene.actionManager.registerAction(new BABYLON.ExecuteCodeAction(BABYLON.ActionManager.OnKeyUpTrigger, function (evt) { if(evt.sourceEvent.keyCode === 27) { console.log("do something!"); }}));Thanks again! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.