draugath

rmlkeyevents - main.lua

Oct 14th, 2014 (edited)
25
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.00 KB | None | 0 0
  1. declare("rmlkeyevents", {})
  2.  
  3. rmlkeyevents.document = rmlui.contexts[1]:LoadDocument("plugins/rmlkeyevents/keyevents.rml") --LoadDocument() does not use the plugin relative directory during plugin loading
  4.  
  5. local function print_event_parameters(event)
  6.     console_print(string.rep("-", 50))
  7.     console_print("Event: "..event.type)
  8.     console_print("Parameters:")
  9.     for _, parameter_name in ipairs({"key_identifier", "ctrl_key", "shift_key", "meta_key", "alt_key", "caps_lock_key", "num_lock_key", "scroll_lock_key"}) do
  10.         local pad = ""
  11.         if parameter_name == "alt_key" then
  12.             pad = "     " -- alt_key is too short, so it screws up the alignment
  13.         end
  14.         local parameter_val = event.parameters[parameter_name]
  15.         console_print(parameter_name..pad, tostring(parameter_val), type(parameter_val))
  16.     end
  17. end
  18.  
  19. rmlkeyevents.myinput = rmlkeyevents.document:GetElementById("myinput")
  20. rmlkeyevents.myinput:AddEventListener("keydown", print_event_parameters)
  21. rmlkeyevents.myinput:AddEventListener("keyup", print_event_parameters)
Advertisement
Add Comment
Please, Sign In to add comment