diff options
-rw-r--r-- | app.lua | 4 | ||||
-rw-r--r-- | keychord.lua | 8 | ||||
-rw-r--r-- | reference.md | 18 |
3 files changed, 22 insertions, 8 deletions
diff --git a/app.lua b/app.lua index 584b17b..89c7bf1 100644 --- a/app.lua +++ b/app.lua @@ -229,7 +229,7 @@ end function App.fake_key_release(key) App.fake_keys_pressed[key] = nil end -function App.modifier_down(key) +function App.key_down(key) return App.fake_keys_pressed[key] end @@ -444,7 +444,7 @@ function App.disable_tests() App.getTime = love.timer.getTime App.getClipboardText = love.system.getClipboardText App.setClipboardText = love.system.setClipboardText - App.modifier_down = love.keyboard.isDown + App.key_down = love.keyboard.isDown App.mouse_move = love.mouse.setPosition App.mouse_down = love.mouse.isDown App.mouse_x = love.mouse.getX diff --git a/keychord.lua b/keychord.lua index 3b43519..16fa48d 100644 --- a/keychord.lua +++ b/keychord.lua @@ -34,19 +34,19 @@ function App.any_modifier_down() end function App.ctrl_down() - return App.modifier_down('lctrl') or App.modifier_down('rctrl') + return App.key_down('lctrl') or App.key_down('rctrl') end function App.alt_down() - return App.modifier_down('lalt') or App.modifier_down('ralt') + return App.key_down('lalt') or App.key_down('ralt') end function App.shift_down() - return App.modifier_down('lshift') or App.modifier_down('rshift') + return App.key_down('lshift') or App.key_down('rshift') end function App.cmd_down() - return App.modifier_down('lgui') or App.modifier_down('rgui') + return App.key_down('lgui') or App.key_down('rgui') end function App.is_cursor_movement(key) diff --git a/reference.md b/reference.md index 5c3c29f..9bef95a 100644 --- a/reference.md +++ b/reference.md @@ -251,8 +251,16 @@ visible on screen. ### keyboard primitives -* `App.modifier_down(key)` -- returns `true` if the given key (doesn't - actually have to be just a modifier) is currently pressed. +* `App.is_cursor_movement(key)` -- return `true` if `key` is a cursor movement + key (arrow keys, page-up/down, home/end) + +* `App.cmd_down()`, `App.ctrl_down`, `App.alt_down()`, `App.shift_down()` -- + predicates for different modifier keys. + +* `App.any_modifier_down()` -- returns `true` if any of the modifier keys is + currently pressed. + +* `App.key_down(key)` -- returns `true` if the given key is currently pressed. (Based on [LÖVE](https://love2d.org/wiki/love.keyboard.isDown).) ### interacting with files @@ -309,6 +317,12 @@ and [the Lua manual](https://www.lua.org/manual/5.1/manual.html#5.7). * `App.setClipboardText(text)` -- stores the string `text` in the clipboard. (Based on [LÖVE](https://love2d.org/wiki/love.system.setClipboardText).) +* `array.find(arr, elem)` -- scan table `arr` for `elem` assuming it's + organized as an array (just numeric indices). + +* `array.any(arr, f)` -- scan table `arr` for any elements satisfying + predicate `f`. Return first such element or `false` if none. + There's much more I could include here; check out [the LÖVE manual](https://love2d.org/wiki) and [the Lua manual](https://www.lua.org/manual/5.1/manual.html). |