Keymon

From OpenEUO
Jump to: navigation, search

Calling Pattern

Call

local km = sl.keymon(t)

Args

t is a table

Results

km is a key monitor closure

Closure Methods

Example

local t = {
  ['ALT SHIFT J']= function() print('ALT SHIFT J') end,
  ['CTRL J']     = function() print('CTRL J')      end,
  ['Q W']        = function() print('Q W')         end,
}
local km = sl.keymon(t)
while true do
  km.refresh()
  wait(30)
end
-> ALT SHIFT J
   ALT SHIFT J
   CTRL J
   ALT SHIFT J
   Q W
   Q W

Description

Use keymon to generate a hotkey processing engine. The sole argument to keymon is a table whose keys are strings made up of hotkey combinations (separated by spaces) and whose values are the associated functions to call. A keymon closure exposes one method, refresh, which will scan all the possible keys necessary to check all of the hotkey combinations, determine which combo, if any, has been pressed, and invokes the associated handler.

Hotkeys are specified by the same strings that are available to getkey. See keymon.refresh for further operational details.

Upon Error

If keymon receives no parameter or if the provided parameter is not a table, keymon issues an error to be handled according to the operant error reporting mode.

See Also