The keyboard
Like the mouse, LDK can read keyboard input. This is risky, as many browsers use keys for shortcuts. Shortcut keys may not be detected by LDK.

The array ldk_keys has the "down" state of all the keys (the value is true when the key is held down, false otherwise). The number of the array index corresponds to the unicode number of the letter you're looking for. Thankfully, the game object contains this function: getUni(char). It returns the unicode value of the character char - for instance, ldk_keys[myGame.getUni("e")] will give you the state of the letter "e" on the keyboard.
LDK also has these pre-defined unicode globals: ldk_up, ldk_left, ldk_down, ldk_right, ldk_space, ldk_esc and ldk_enter.

Last edited Dec 13, 2009 at 11:02 PM by larztheloser, version 1


No comments yet.