Classes (extension) | GUI | External Control > Keyboard

KeyDownActionsEditor : KeyDownActions : Object

an editor allowing to set keyboard-shortcuts resp. edit the actions connmected to the shortcuts.


KeyDownActionsEditor allows you to define and edit an unlimited number of key-down actions for a given GUI-element. It's based on View: -keyDownAction but adds some WYSIWYG functionality within its GUI.

To edit or remove a shortcut you'll have to click the edit-button first. The shortcut-field (next to the label "shortcut:") will get set to whatever key you hit - also during editing the action - it's advisable to first edit the action and to set the key afterwards.

Class Methods, name, bounds, shortcutsDict, showMods: true)

Create a new KeyDownActionsEditor for the given shortcuts in shortcutsDict



a View - if none is provided it will get created internally


a String or a Symbol, added to the window's title.


a Rect, denoting position and size


a Dictionary shortcuts (keys and actions) to be displayed in the editor


whether to expose modifier-keys in the editor (e.g. set to false for editing KeyDownActions: *globalShortcuts)


a KeyDownActionsEditor

Inherited class methods

Instance Methods


Query the values currently set in the editor.



Set the keyDownActions of the given View to the current values of the editor.

NOTE: Though in most cases argument view will be an object of type View this doesn't necessarily have to be the case. At least the following classes do have a method keyDownAction implemented as well: ViewHolder2, SplineGui, ScaledUserView, SMPTEView and possibly others as well well. A KeyDownActionsEditor may be used in connection with these too. Note also the corresponding class-method KeyDownActions: *setShortcuts which works independently from a given KeyDownActionsEditor


this (a KeyDownActionsEditor)


The editor's Window


Inherited instance methods


// the editor is a GUI element that can be initialised
// as part of a composite view or a standalone
k =;

// just an example dict
// you shouldn't need to do this
// a KeyDownActionsEditor can be initialised without shortcuts as well
// all shortcuts added via GUI will get stored in an IdentityDictionary
// like the one below
// note the mixed keys

t = IdentityDictionary[
    'alt + i' -> (
        func: "{ |view| view.background_( }",
        keyCode: KeyDownActions.keyCodes[$i],
        modifierQt: KeyDownActions.modifiersQt[\alt],
        modifierCocoa: KeyDownActions.modifiersCocoa[\alt]
    $i -> (
        func: "{ |view| view.background_( }",
        keyCode: KeyDownActions.keyCodes[$i]

// create a window and set its shortcuts to what is in k.result
w = Window("shortcuts test").onClose_({ f.close }).front;

f = Window("Shortcuts Editor", 400@300).front;
k = KeyDownActionsEditor(f, bounds: f.bounds.width@(f.bounds.height-40), shortcutsDict: t);
b = Button(f, Rect(f.bounds.width-100, f.bounds.height-30, 90, 20)).states_([["set Shortcuts", Color.white,]]).action_({ |btn| k.result.postln; k.setShortcuts(w.view) });