sdlGetKeyName function
Get a human-readable name for a key.
If the key doesn't have a name, this function returns an empty string ("").
\param key the desired SDL_Keycode to query. \returns a UTF-8 encoded string of the key name.
\threadsafety This function is not thread safe.
\since This function is available since SDL 3.1.3.
\sa SDL_GetKeyFromName \sa SDL_GetKeyFromScancode \sa SDL_GetScancodeFromKey
extern SDL_DECLSPEC const char * SDLCALL SDL_GetKeyName(SDL_Keycode key)
Implementation
String? sdlGetKeyName(int key) {
final sdlGetKeyNameLookupFunction = libSdl3.lookupFunction<
Pointer<Utf8> Function(Uint32 key),
Pointer<Utf8> Function(int key)>('SDL_GetKeyName');
final result = sdlGetKeyNameLookupFunction(key);
if (result == nullptr) {
return null;
}
return result.toDartString();
}