Package io.github.ocelot.window.input
Class KeyboardHandler
java.lang.Object
io.github.ocelot.window.input.KeyboardHandler
- All Implemented Interfaces:
WindowEventListener
Tracks pressed keys using keycode and scancode.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanisKeyPressed(int keyCode) Checks to see if the specified key is pressed.booleanisKeyPressed(int keyCode, int scanCode) Checks to see if the specified key or scan code is pressed.voidkeyPressed(Window window, int key, int scanCode, KeyMods mods) Called when a key on the keyboard is pressed.voidkeyReleased(Window window, int key, int scanCode, KeyMods mods) Called when a key on the keyboard is released.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface io.github.ocelot.window.WindowEventListener
charTyped, cursorEntered, filesDropped, focusChanged, framebufferResized, keyRepeated, mouseMoved, mousePressed, mouseReleased, mouseScrolled, windowClosed, windowMoved, windowResized
-
Constructor Details
-
KeyboardHandler
public KeyboardHandler()
-
-
Method Details
-
keyPressed
Description copied from interface:WindowEventListenerCalled when a key on the keyboard is pressed.- Specified by:
keyPressedin interfaceWindowEventListener- Parameters:
window- The window that fired the eventkey- The universal key codescanCode- The machine-specific scan codemods- The keyboard modifier flags set when the key was pressed
-
keyReleased
Description copied from interface:WindowEventListenerCalled when a key on the keyboard is released.- Specified by:
keyReleasedin interfaceWindowEventListener- Parameters:
window- The window that fired the eventkey- The universal key codescanCode- The machine-specific scan codemods- The keyboard modifier flags set when the key was released
-
isKeyPressed
public boolean isKeyPressed(int keyCode, int scanCode) Checks to see if the specified key or scan code is pressed.- Parameters:
keyCode- The id of the key orGLFW.GLFW_KEY_UNKNOWNto defer to the scan codescanCode- The device-specific scan code- Returns:
- Whether that key is pressed
-
isKeyPressed
public boolean isKeyPressed(int keyCode) Checks to see if the specified key is pressed.isKeyPressed(int, int)should be used if scanCode is available to support device-specific keys.- Parameters:
keyCode- The id of the key- Returns:
- Whether that key is pressed
-