glfwGetKey

Returns the last reported state of a keyboard key for the specified window.

This function returns the last state reported for the specified key to the specified window. The returned state is one of GLFW_PRESS or GLFW_RELEASE. The higher-level action GLFW_REPEAT is only reported to the key callback.

If the @ref GLFW_STICKY_KEYS input mode is enabled, this function returns GLFW_PRESS the first time you call it for a key that was pressed, even if that key has already been released.

The key functions deal with physical keys, with key tokens named after their use on the standard US keyboard layout. If you want to input text, use the Unicode character callback instead.

The modifier key bit masks are not key tokens and cannot be used with this function.

__Do not use this function__ to implement text input.

extern (C) @nogc nothrow __gshared
int
glfwGetKey

Parameters

window GLFWwindow*

The desired window.

key int

The desired keyboard key. GLFW_KEY_UNKNOWN is not a valid key for this function.

Return Value

Type: int

One of GLFW_PRESS or GLFW_RELEASE.

Errors: Possible errors include @ref GLFW_NOT_INITIALIZED and @ref GLFW_INVALID_ENUM.

Thread Safety

This function must only be called from the main thread.

@sa @ref input_key

Meta

Since

Added in version 1.0. @glfw3 Added window handle parameter.

Ingroup: input