2.2.1 Key Methods

Take your time to examine these methods:

 
Kb.bp(KB_N) // true if N was pressed down in this frame. 
Kb.br(KB_E) // true if E was released in this frame. 
Kb.b (KB_R) // true while R is being held down 
Kb.bd(KB_D) // true if a double tap occurred on D  
5

Even though we use the object Kb instead of Ms, most functions are exactly the same. But instead of using the number of a mouse button as an argument, you will now enter a keyboard code. This code will always start with KB_, followed by a character or a number. Other options are:






Functions
Control
Modifiers
Arrows
Numpad





KB_F1 KB_ESC KB_LCTRL KB_LEFT KB_NPDIV





KB_F2 KB_ENTERKB_RCTRLKB_RIGHTKB_NPENTER





KB_SPACEKB_LSHIFT KB_UP KB_NP1





KB_F12 KB_BACK KB_RSHIFTKB_DOWN KB_NP2





KB_TAB





A complete list of all keys can be found at Esenthel Engine Input Input Buttons.

Exercise
Create an application with a dot on the screen. Use the arrow keys to move this dot. Every time an arrow key is pressed, you move this dot 0.1 units in that direction.

The dot itself will be drawn in green, unless the spacebar is held down. If so, draw the dot in red.