pub unsafe extern "C" fn glfwSetKeyCallback(
window: *mut GLFWwindow,
callback: Option<unsafe extern "C" fn(*mut GLFWwindow, i32, i32, i32, i32)>,
) -> Option<unsafe extern "C" fn(*mut GLFWwindow, i32, i32, i32, i32)>Expand description
@brief Sets the key callback.
This function sets the key callback of the specified window, which is called when a key is pressed, repeated or released.
The key functions deal with physical keys, with layout independent [key tokens](@ref keys) named after their values in the standard US keyboard layout. If you want to input text, use the [character callback](@ref glfwSetCharCallback) instead.
When a window loses input focus, it will generate synthetic key release events for all pressed keys with associated key tokens. You can tell these events from user-generated events by the fact that the synthetic ones are generated after the focus loss event has been processed, i.e. after the [window focus callback](@ref glfwSetWindowFocusCallback) has been called.
The scancode of a key is specific to that platform or sometimes even to that
machine. Scancodes are intended to allow users to bind keys that don’t have
a GLFW key token. Such keys have key set to GLFW_KEY_UNKNOWN, their
state is not saved and so it cannot be queried with @ref glfwGetKey.
Sometimes GLFW needs to generate synthetic key events, in which case the scancode may be zero.
@param[in] window The window whose callback to set.
@param[in] callback The new key callback, or NULL to remove the currently
set callback.
@return The previously set callback, or NULL if no callback was set or the
library had not been [initialized](@ref intro_init).
@callback_signature @code void function_name(GLFWwindow* window, int key, int scancode, int action, int mods) @endcode For more information about the callback parameters, see the [function pointer type](@ref GLFWkeyfun).
@errors Possible errors include @ref GLFW_NOT_INITIALIZED.
@thread_safety This function must only be called from the main thread.
@sa @ref input_key
@since Added in version 1.0. @glfw3 Added window handle parameter and return value.
@ingroup input