Give access to the real-time state of the keyboard. More...
#include <Keyboard.hpp>
Public Types | |
enum | Key { Unknown = -1, A = 0, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W, X, Y, Z, Num0, Num1, Num2, Num3, Num4, Num5, Num6, Num7, Num8, Num9, Escape, LControl, LShift, LAlt, LSystem, RControl, RShift, RAlt, RSystem, Menu, LBracket, RBracket, SemiColon, Comma, Period, Quote, Slash, BackSlash, Tilde, Equal, Dash, Space, Return, BackSpace, Tab, PageUp, PageDown, End, Home, Insert, Delete, Add, Subtract, Multiply, Divide, Left, Right, Up, Down, Numpad0, Numpad1, Numpad2, Numpad3, Numpad4, Numpad5, Numpad6, Numpad7, Numpad8, Numpad9, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, F13, F14, F15, Pause, KeyCount } |
Key codes. More... | |
Static Public Member Functions | |
static bool | isKeyPressed (Key key) |
Check if a key is pressed. | |
Give access to the real-time state of the keyboard.
sf::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, sf::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.
Usage example:
Definition at line 40 of file Keyboard.hpp.
enum sf::Keyboard::Key |
Key codes.
Definition at line 48 of file Keyboard.hpp.
|
static |
Check if a key is pressed.
key | Key to check |