2 summary:: Respond to the state of a key
3 related:: Classes/MouseButton, Classes/MouseX, Classes/MouseY
4 categories:: UGens>User interaction
8 Respond to the state of a key.
11 Note that this UGen does not prevent normal typing. It therefore may be
12 helpful to select a GUI window rather than an SC document when using
13 KeyState, as the latter will be altered by any keystrokes.
21 The keycode value of the key to check. This corresponds to the
22 keycode values passed into the keyDownActions of SCViews. See the
26 The value to output when the key is not pressed.
29 The value to output when the key is pressed.
42 // execute the code below to find out a key's keycode
43 // the char and keycode of any key you press will be printed in the post window
45 w = Window.new("I catch keystrokes");
46 w.view.keyDownAction = { arg view, char, modifiers, unicode, keycode; [char, keycode].postln; };
50 // then execute this and then press the 'j' key
52 w.front; // something safe to type on
53 { SinOsc.ar(800, 0, KeyState.kr(38, 0, 0.1)) }.play;