Give access to the real-time state of the keyboard.
1 if (Keyboard.isKeyPressed(Keyboard.Key.Left)) 2 { 3 // move left... 4 } 5 else if (Keyboard.isKeyPressed(Keyboard.Key.Right)) 6 { 7 // move right... 8 } 9 else if (Keyboard.isKeyPressed(Keyboard.Key.Escape)) 10 { 11 // quit... 12 }
*
$(JOYSTICK_LINK), $(MOUSE_LINK), $(TOUCH_LINK)
$(U Keyboard) provides an interface to the state of the keyboard. It only contains static functions (a single keyboard is assumed), so it's not meant to be instanciated. * This class allows users to query the keyboard state at any time and directly, without having to deal with a window and its events. Compared to the KeyPressed and KeyReleased events, $(U Keyboard) can retrieve the state of a key at any time (you don't need to store and update a boolean on your side in order to know if a key is pressed or released), and you always get the real state of the keyboard, even if keys are pressed or released when your window is out of focus and no event is triggered. *