Skip to content

Latest commit

 

History

History
65 lines (43 loc) · 1.47 KB

File metadata and controls

65 lines (43 loc) · 1.47 KB

Keybind

Summary

geode.Keybind reads and writes key combinations. A keybind is a plain table.

Field Type Notes
key number a key code
modifiers number a bit mask of held modifier keys

Use geode.cocos.enumKeyCodes.KEY_* values for key. Use geode.KeyboardModifier constants for modifiers.

fromString returns nil and an error message on a bad string. See globals Error shapes.

fromString

geode.Keybind.fromString(str: string) -> ({ key: number, modifiers: number }?, string?)

Parses a string such as "Ctrl+A" into a keybind. Modifier and key tokens use + with no spaces. Returns the keybind, or nil and an error message.

toString

geode.Keybind.toString(keybind: { key: number, modifiers: number }) -> string

Turns a keybind back into a readable string.

createNode

geode.Keybind.createNode(keybind: { key: number, modifiers: number }) -> CCNode?

Builds a node that shows the keybind. Returns the node, or nil if it could not be made.

Example

local kb, err = geode.Keybind.fromString("Ctrl+A")
if not kb then return print(err) end

print(geode.Keybind.toString(kb)) -- Ctrl+A

local node = geode.Keybind.createNode(kb)
if node then someMenu:addChild(node) end

Related

Source

  • src/bindings/geode/GeodeSmallBindings.cpp