KeyState:
Filter:
Classes | UGens > User interaction

KeyState : UGen : AbstractFunction : Object

Respond to the state of a key
Source: MacUGens.sc

Description

Respond to the state of a key.

NOTE: Note that this UGen does not prevent normal typing. It therefore may be helpful to select a GUI window rather than an SC document when using KeyState, as the latter will be altered by any keystrokes.
WARNING: This UGen will not work for Linux users using Wayland, as the Wayland protocol does not allow a global keyboard or mouse state to be captured. The UGen will return 0.0 as constant value. For more information see https://github.com/supercollider/supercollider/issues/4544
WARNING: MacOS users will need to add the SuperCollider application to the Input Monitoring group in the Privacy & Security preferences to have all keys captured. See https://support.apple.com/en-us/guide/mac-help/mchl4cedafb6/mac

Class Methods

KeyState.kr(keycode: 0, minval: 0, maxval: 1, lag: 0.2)

Arguments:

keycode

The keycode value of the key to check. This corresponds to the keycode values passed into the keyDownActions of SCViews. See the example below.

minval

The value to output when the key is not pressed.

maxval

The value to output when the key is pressed.

lag

A lag factor.

Inherited class methods

Instance Methods

Inherited instance methods

Examples