glfwGetKey function

int glfwGetKey(
  1. Pointer<GLFWwindow> window,
  2. int key
)

! @brief 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 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(@ref keys) 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(@ref mods) are not key tokens and cannot be used with this function.

Do not use this function to implement text input(@ref input_char).

@paramin window The desired window. @paramin key The desired keyboard key(@ref keys). GLFW_KEY_UNKNOWN is not a valid key for this function. @return 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

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

@ingroup input

GLFWAPI int glfwGetKey(GLFWwindow* window, int key)

Implementation

int glfwGetKey(Pointer<GLFWwindow> window, int key) {
  final glfwGetKeyLookupFunction = libglfw.lookupFunction<
      Int32 Function(Pointer<GLFWwindow> window, Int32 key),
      int Function(Pointer<GLFWwindow> window, int key)>('glfwGetKey');
  return glfwGetKeyLookupFunction(window, key);
}