https://github.com/antix-development/keymanager
A simple keypress manager for Gideros
https://github.com/antix-development/keymanager
Last synced: about 1 month ago
JSON representation
A simple keypress manager for Gideros
- Host: GitHub
- URL: https://github.com/antix-development/keymanager
- Owner: Antix-Development
- License: gpl-3.0
- Created: 2017-07-21T08:48:36.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2017-10-28T22:00:42.000Z (over 8 years ago)
- Last Synced: 2025-01-07T21:53:03.809Z (over 1 year ago)
- Language: Lua
- Homepage:
- Size: 16.6 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# KeyManager
A simple key manager for Gideros
KeyManager is a class to manage key presses in Gideros. With it you can register a callback to be executed when a key is pressed or released, and determine the key held state of any key at any time.
```Lua
-- Example use
local keys = KeyManager.new()
keys:registerDown(KeyCode.E, function()
print("e is down ") -- this will happen every time the e key is pressed
end)
keys:registerUp(KeyCode.E, function()
print("e is up ") -- this will happen every time the e key is released
end)
local function onEnterFrame(e)
if keys:state(KeyCode.A) then
print("a held") -- this will happen when the a key is held down
end
end
stage:addEventListener(Event.ENTER_FRAME, onEnterFrame)
```