-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathof.keyboard.pd
22 lines (22 loc) · 1.25 KB
/
of.keyboard.pd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#N canvas 301 50 870 631 12;
#X obj 32 578 outlet;
#X obj 32 38 ofelia d \$0keyboard \; local log = ofLog("ofKeyPressed")
\; local canvas = ofCanvas(this) \; local args = canvas:getArgs() \;
local keycode = args[1] \; \; function M.new() \; if args[1] == 1 then
keycode = 1 end \; ofWindow.addListener("keyPressed" \, this) \; end
\; \; function M.free() \; ofWindow.removeListener("keyPressed" \,
this) \; end \; \; function M.keyPressed(e) \; if keycode then return(e.key)
\; else if e.key == 57357 then return ("Up") \; elseif e.key == 57359
then return ("Down") \; elseif e.key == 57356 then return ("Left")
\; elseif e.key == 57358 then return ("Right") \; elseif e.key == 8
then return ("Return") \; elseif e.key == 9 then return ("Tab") \;
elseif e.key == 13 then return ("Enter") \; elseif e.key == 32 then
return ("Space") \; elseif e.key == 3680 then return ("L_Shift") \;
elseif e.key == 3681 then return ("R_Shift") \; elseif e.key == 3682
then return ("Ctrl") \; elseif e.key == 3684 then return ("L_alt")
\; elseif e.key == 3685 then return ("R_alt") \; elseif e.key == 3686
then return ("L_cmd") \; elseif e.key == 3687 then return ("R_cmd")
\; elseif e.key == 27 then return ("Esc") \; else return (utf8.char(e.key))
end end \; end;
#X f 115;
#X connect 1 0 0 0;