diff --git a/docs/events/Key b/docs/events/Key new file mode 100644 index 0000000..adc38fd --- /dev/null +++ b/docs/events/Key @@ -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)`
+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)`
+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) +```