How do I detect Keyboard pressed which?

For developers using the Construct 2 Javascript SDK

Post » Fri Mar 24, 2017 4:09 pm

Hi,

My intention is to extend the keyboard plugin to be able to detect language specific characters.

Looking at this website:
http://javascript.info/tutorial/keyboard-events

I can see that there is a parameter: which:

This is used to properly detect a symbol:
Code: Select all
// event.type must be keypress
function getChar(event) {
  if (event.which == null) {
    return String.fromCharCode(event.keyCode) // IE
  } else if (event.which!=0 && event.charCode!=0) {
    return String.fromCharCode(event.which)   // the rest
  } else {
    return null // special key
  }
}



EDIT:
I can see that there is :
instanceProto.onKeyDown

but no on key press

Can anyone help?
B
34
S
8
G
4
Posts: 158
Reputation: 3,783

Return to Javascript SDK

Who is online

Users browsing this forum: No registered users and 0 guests