From 939be0764e245e15a5740f38f49b217b55b94825 Mon Sep 17 00:00:00 2001 From: Robert Jelic <36573031+NoryiE@users.noreply.github.com> Date: Mon, 20 Jun 2022 23:13:07 +0200 Subject: [PATCH] Create Key --- docs/events/Key | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 docs/events/Key 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) +```