sdlGetKeyboardState function keyboard
Get a snapshot of the current state of the keyboard.
The pointer returned is a pointer to an internal SDL array. It will be valid for the whole lifetime of the application and should not be freed by the caller.
A array element with a value of true means that the key is pressed and a value of false means that it is not. Indexes into this array are obtained by using SDL_Scancode values.
Use SDL_PumpEvents() to update the state array.
This function gives you the current state after all events have been processed, so if a key or button has been pressed and released before you process events, then the pressed state will never show up in the SDL_GetKeyboardState() calls.
Note: This function doesn't take into account whether shift has been pressed or not.
Note that this function is "thread safe," in that calling it from two threads at once will return the same array and that it won't be reallocated or free'd without warning, as more events arrive, the contents of this array may change without warning or any sort of thread synchronization. For apps that need precision, it is better to use the key events in the SDL event queue.
\param numkeys if non-NULL, receives the length of the returned array. \returns a pointer to an array of key states.
\threadsafety It is safe to call this function from any thread.
\since This function is available since SDL 3.2.0.
\sa SDL_PumpEvents \sa SDL_ResetKeyboard
extern SDL_DECLSPEC const bool * SDLCALL SDL_GetKeyboardState(int *numkeys)
See also:
Implementation
Pointer<Bool> sdlGetKeyboardState(Pointer<Int32> numkeys) {
final sdlGetKeyboardStateLookupFunction = _libSdl
.lookupFunction<
Pointer<Bool> Function(Pointer<Int32> numkeys),
Pointer<Bool> Function(Pointer<Int32> numkeys)
>('SDL_GetKeyboardState');
return sdlGetKeyboardStateLookupFunction(numkeys);
}