key

From Pdpedia

Jump to: navigation, search
key
{{{example_image}}}
caption
Description: numeric key values from keyboard
Abbreviation:  
Library: vanilla
Author(s): Miller S. Puckette and others
Developer(s):
Release version:
Release date: 2007
Status: active
Dependencies:
License: BSD
Website: http://crca.ucsd.edu/~msp/software.html
Programming Language:
Platform(s): GNU/Linux, Mac OS X, Windows
Language: English
Data type(s): message
Distribution(s): DesireData, PDa, Pd-extended, Pd-vanilla, puredata debian package, pure:dyne



Native Pd Objects

- GRAB KEYBOARD

Click here to start...

REACTING TO USER INPUT

OBJECT OUTLETS

Most, if not all, programming environments provide us with tools to capture 'user initiated' events from the operating system. Keyboard input, mouse clicks, and mouse movements are the most common events in this 'user event' category.

None

INLETS:

The number at this outlet represents the numeric "ID" of a key on the computer's keyboard. This event occurs when the key is pressed down. Only one event is captured at a time.

This object does not accept arguments of any type.

ARGUMENTS:

Externals and other object libraries

Please see the following sub-patch called "More_Info" for detailed information about the objects' outlets. The outlets of this 'object group' provide Pd with information about keystrokes on your computer's keyboard.

OUTLETS:

Some keys, such as SHIFT or the F1-F12 series all produce a zero, but we can see by the [bng] that the event is not ignored completely...but the numeric "ID" of the key is not captured successfully. (This may produce different results on different systems.)

Pd's [key], [keyup], and [keyname] are complimented by the externals such as [gemmouse] and [nimouse] to provide us with a full range of tools to gleen a user's activities at the computer.

EXAMPLES:

It's interesting to note that, with these tools, PD can mimic some of the functions in other languages - Javascript for example has:

Also note that key combinations, such as SHIFT+7 produce a different result than SHIFT or 7 alone.

To see this example in action, simply type something on your keyboard.

onKeyDown

The number at this outlets represents the numeric "ID" of a key on the computer's keyboard. This even occurs when the key is released. Only one event is captured at a time.

onKeyUp

[key] and [keyup] report the (system dependent) numbers of "printing" keys of the keyboard. [keyname] gives the symbolic name of the key, with a 1 if it's up or 0 if it's down, and works with non-printing keys like shift or "F1".

onKeyPress

hmmm...wouldn't it be great if Pd also gave us onChange \, onBlur, onFocus, onClick, onDblClick, onDragDrop, onLoad \, onMouseDown, onMouseOver, onMouseOut, onMouseMove, onUnload...?

The [key] and [keyup] objects can mimic the functionality of the [noteon] and [noteoff] objects. A key combination such as SHIFT+7 could be considered a 'chord'!

Caveat -- this only works if Pd actually gets the key events which can depend on the stacking order of windows and/or the pointer location. This is dependent on the system.

This object captures both the "keydown" and "keyup" events. The left inlet produces a 1 when a key goes down, and a zero when the key goes up. The right outlet produces a symbol which represents the name of the key.

SEE ALSO:

for more on HIDs:

- Dave Sabine, July 11, 2003



Contents

[edit] Inlets

[edit] Outlets

[edit] Arguments

[edit] Messages

Personal tools