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

KeyCodeResponder : Object
ExtensionExtension

register responder functions for keycode and modifier combinations
Subclasses: KeyResponder

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

KeyCodeResponder.normalModifier

KeyCodeResponder.capsModifier

KeyCodeResponder.shiftModifier

KeyCodeResponder.controlModifier

KeyCodeResponder.optionModifier

KeyCodeResponder.functionKeyModifier

KeyCodeResponder.commandModifier

KeyCodeResponder.register(keycode, shift, caps, opt, cntl, function)

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

KeyCodeResponder.registerAll( ... sets)

Arguments:

... sets

KeyCodeResponder.clear

KeyCodeResponder.remove

KeyCodeResponder.resetKeycode(keycode)

Arguments:

keycode

KeyCodeResponder.tester

KeyCodeResponder.new

KeyCodeResponder.registerKeycode(modifier, keycode, function)

Arguments:

modifier
keycode
function

KeyCodeResponder.registerKeycodeAll( ... sets)

Arguments:

... sets

KeyCodeResponder.value(view, keycode, modifier, unicode)

Arguments:

view
keycode
modifier
unicode

KeyCodeResponder.global

KeyCodeResponder.at(address)

Arguments:

address

KeyCodeResponder.put(address, val)

Arguments:

address
val

KeyCodeResponder.pushForKeycode(keycode, requireMask, denyMask, function, description)

Arguments:

keycode
requireMask
denyMask
function
description

KeyCodeResponder.maskToString(m)

Arguments:

m

Inherited class methods

Instance Methods

.dict

.dict = value

.normal( ... associations)

note the association ( key -> value )

Arguments:

... associations

.shift( ... associations)

Arguments:

... associations

.control( ... associations)

Arguments:

... associations

.option( ... associations)

Arguments:

... associations

.register(keycode, shift, caps, opt, cntl, function, description)

Arguments:

keycode
shift
caps
opt
cntl
function
description

.clear

.remove

++(that)

Arguments:

that

.registerKeycode(modifier, keycode, function)

Arguments:

modifier
keycode
function

.registerKeycodeAll( ... sets)

Arguments:

... sets

.value(view, char, modifier, unicode, keycode)

Arguments:

view
char
modifier
unicode
keycode

.at(key)

Arguments:

key

.put(key, value)

Arguments:

key
value

.pushForKeycode(keycode, requireMask, denyMask, function, description)

Arguments:

keycode
requireMask
denyMask
function
description

.report

.guiClass

Inherited instance methods

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: