Grab keyboard and read pressed keys, calling the least callback function from
stack at each key press, until stack is empty.
Calling run with the same callback again will bring the callback
to the top of the stack.
The callback function is passed three arguments:
a table containing modifiers keys, a string with the key pressed and a
string with either "press" or "release" to indicate the event type.
A callback can return false to pass the events to the next key grabber in the stack.
Parameters:
- g
The key grabber callback that will get the key events until it will be deleted or a new grabber is added.
Returns:
the given callback `g`
Usage:
The following function can be bound to a key, and used to resize a client
using keyboard.
function resize(c)
local grabber = awful.keygrabber.run(function(mod, key, event)
if event == "release" then return end
if key == 'Up' then awful.client.moveresize(0, 0, 0, 5, c)
elseif key == 'Down' then awful.client.moveresize(0, 0, 0, -5, c)
elseif key == 'Right' then awful.client.moveresize(0, 0, 5, 0, c)
elseif key == 'Left' then awful.client.moveresize(0, 0, -5, 0, c)
else awful.keygrabber.stop(grabber)
end
end)
end