Create Key
This commit is contained in:
39
docs/events/Key
Normal file
39
docs/events/Key
Normal file
@@ -0,0 +1,39 @@
|
||||
Here we will talk about keyboard events and how you can manipulate them. There are 2 possible key events you can add to almost every visual object.
|
||||
|
||||
# onKey
|
||||
`onKey(self, event, key)`<br>
|
||||
The computercraft event which triggers this method is `key`.
|
||||
Any visual object can register onKey events.
|
||||
|
||||
Here is a example on how to add a onKey event to your frame:
|
||||
|
||||
```lua
|
||||
local basalt = dofile("basalt.lua")
|
||||
|
||||
local mainFrame = basalt.createFrame("myMainFrame"):show()
|
||||
local subFrame = mainFrame:addFrame("subFrame"):setPosition(3,3):setSize(18,6):setBar("Sub Frame",colors.black):showBar():show()
|
||||
|
||||
function openSubFrame()
|
||||
subFrame:show()
|
||||
end
|
||||
mainFrame:onKey(openSubFrame)
|
||||
```
|
||||
|
||||
# onKeyUp
|
||||
`onKeyUp(self, event, key)`<br>
|
||||
The computercraft event which triggers this method is `key_up`.
|
||||
Any visual object can register onKeyUp events.
|
||||
|
||||
Here is a example on how to add a onKeyUp event to your frame:
|
||||
|
||||
```lua
|
||||
local basalt = dofile("basalt.lua")
|
||||
|
||||
local mainFrame = basalt.createFrame("myMainFrame"):show()
|
||||
local subFrame = mainFrame:addFrame("subFrame"):setPosition(3,3):setSize(18,6):setBar("Sub Frame",colors.black):showBar():show()
|
||||
|
||||
function openSubFrame()
|
||||
subFrame:show()
|
||||
end
|
||||
mainFrame:onKeyUp(openSubFrame)
|
||||
```
|
||||
Reference in New Issue
Block a user