Key Pressed Event

29 views
Skip to first unread message

s.kyle....@gmail.com

unread,
May 17, 2013, 11:46:12 PM5/17/13
to mel...@googlegroups.com
Hi, I'm new to melonjs and js/html5 gamedev in general. I am planning on making a screen for my game to customize controls. Is there a way to listen for a key pressed event and grab the key code to pass to the input.bindKey(keycode, action, lock) method? 

Thanks,
Kyle

Jay Oster

unread,
May 18, 2013, 2:53:49 AM5/18/13
to mel...@googlegroups.com, s.kyle....@gmail.com
Hello!

You can use standard JavaScript to listen for arbitrary key events:

window.addEventListener("keydown", function (e) {
    console.log("keycode: " + e.which);
}, true);
Reply all
Reply to author
Forward
0 new messages