KeyCodeResponder:
Filter:
crucial-library/Classes (extension) | Libraries > crucial > Keyboard | External Control > Keyboard

KeyCodeResponder
ExtensionExtension

register responder functions for keycode and modifier combinations

Description

Handles multiple registrations for keycode and modifier combinations. This object should be used as the keydown or keyup action for a view in place of a function.

KeyCodes are hardware dependant, and change from machine to machine. Its a simple way to hook up keys to respond, but it won't transfer to other people's computers.

see also [UnicodeResponder] which matches based on the unicode, though the physical location of the key may still vary according zee nationality ov der keyboard. Command modifiers cannot be registered using the register method; use registerKeycode instead (see example below).

Class Methods

.normalModifier

.capsModifier

.shiftModifier

.controlModifier

.optionModifier

.functionKeyModifier

.commandModifier

.register

for shift, caps,opt,cntl true indicates a required modifier false indicates an excluded modifier nil expresses that you really don't care one way or the other

Arguments:

keycode
shift
caps
opt
cntl
function

.registerAll

Arguments:

... sets

.clear

.remove

.resetKeycode

Arguments:

keycode

.tester

.new

.registerKeycode

Arguments:

modifier
keycode
function

.registerKeycodeAll

Arguments:

... sets

.value

Arguments:

view
keycode
modifier
unicode

.global

.at

Arguments:

address

.put

Arguments:

address
val

.pushForKeycode

Arguments:

keycode
requireMask
denyMask
function
description

.maskToString

Arguments:

m

Instance Methods

.dict

.normal

note the association ( key -> value )

Arguments:

... associations

.shift

Arguments:

... associations

.control

Arguments:

... associations

.option

Arguments:

... associations

.register

Arguments:

keycode
shift
caps
opt
cntl
function
description

.clear

.remove

++

Arguments:

that

.registerKeycode

Arguments:

modifier
keycode
function

.registerKeycodeAll

Arguments:

... sets

.value

Arguments:

view
char
modifier
unicode
keycode

.at

Arguments:

key

.put

Arguments:

key
value

.pushForKeycode

Arguments:

keycode
requireMask
denyMask
function
description

.report

.guiClass

Examples

Use this to post the keycodes

Any player's gui can have its keyDownAction set

focus on the slider. notice that every key stroke is passed, the slider does not swallow them.

or you can use KeyCodeResponder

This means that when ever the player is focused (any of its controls is in focus), these keys will be active providing that the view that is actually in focus doesn't handle the key event (it should have a nil keyDownAction function or pass nil).

You can concatenate KeyCodeResponders using ++

global keydowns not yet tested....

This is very useful when using CAPS-LOCK to switch interface modes etc.

Only one function per deny/require mask combination is possible per keycode:

The simpler, older method is :

whereby that modifier and only that modifier will fire the funtion. see View for modifier values or use this :

// using characters

Gotcha: it is easy to forget that you registered a function with KeyCodeResponder that holds a reference to a large object. Garbage Collection will not remove the object until you have released your reference.

solution: