Smart macro reference

Smart macros enable the advanced customization of your UHK and its modules.

This documentation is a reference for smart macros, but let's start with a quick guide on how to use them.

Basic concepts and usage

See the following screenshot, which shows a macro named $onInit containing a command macro action that contains multiple macro commands:

$onInit is a special macro name. It's a macro event that executes each time your UHK gets powered and when you save its configuration.

set module.trackball.baseSpeed 1 is a macro command that sets the base speed of the trackball module to 1.

Comments are allowed after the // characters per line. You can comment out commands or add helpful comments.

Macro commands work in any macros, not only in macro events, and you can bind them to any key. This way, you can make Fn + 1 set your trackball base speed to 1 and make Fn + 2 set it to 2, for example.

After creating a macro command action, it becomes in-place editable, so you can simply click into it to edit its commands. You'll likely save your macro commands many times to tweak them, in which case, it's quicker to hit Ctrl + S instead of clicking the "Save to keyboard" button.

When your UHK encounters an invalid macro command, its LED display will show ERR. The printStatus command reveals the cause of the error. Create a macro named printStatus containing the printStatus command:

Bind the macro to a shortcut, such as Fn + ` :

Then open an editor and hit Fn + ` to see the error message.

Last but not least, when a command macro action is selected, many interactive widgets, such as sliders, comboboxes, and checkboxes appear in this documentation, some depending on the currently attached modules. By interacting with these widgets, the relevant commands appear in the current command macro action without writing any code:

Macro events

Macro events are specially named macros that are executed on select occasions. When your UHK powers up and when you save its configuration, the relevant macro events are executed in the following order:

  1. The $onInit event is always executed.
  2. The $onKeymapChange {keymapId} event, such as $onKeymapChange QWR, is executed when a keymap, such as QWR, is activated.

Macro commands

Following is the list of available macro commands.

printStatus

When the UHK encounters an invalid macro command, the LED display will display ERR, and the status buffer will contain the error message. This command "types" the content of the status buffer for debugging purposes.

We recommend binding this command to a shortcut, such as Fn + `, for easy accessibility and triggering it in a text editor when encountering an error.

resetTrackpoint

The trackpoint module sometimes makes the mouse cursor drift. Drifting happens because the auto-calibration mechanism of the trackpoint hardware sometimes kicks in when resting a finger on the trackpoint for several seconds. This issue also affects IBM ThinkPad trackpoints, but given their position, they're not as affected by resting fingers as the UHK trackpoint module.

Avoiding resting fingers on the trackpoint should make this a non-issue. Alternatively, this command resets the trackpoint and recovers it from drift conditions.

set

The set command sets variables that affect the behavior of the UHK and its modules. This command has many different parameters, which are explained below.

set » module speeds

Sets module speeds. These settings are not useful for the key cluster due to the limited resolution of its mini trackball.

Syntax is set module.{module}.{property} {value}
{{moduleDescriptions[module]}}
{{speedProp.desc}}

set » module speed divisors

Sets module speed divisors. These settings are not useful for the key cluster due to the limited resolution of its mini trackball.

Syntax is set module.{module}.{property} {value}
{{moduleDescriptions[module]}}
{{speedProp.desc}}

set » module axis locking

When first moving in a navigation mode with axis locking enabled, the axis is locked to one of the axes. The following variables define axis locking behavior.

Syntax is set module.{module}.{property} {value}
{{moduleDescriptions[module]}}
Scroll axis lock enabled
Caret axis lock enabled
Axis lock first tick skew
Axis lock skew

set » module scroll direction

Inverts the vertical scroll direction per module.

Syntax is set module.{module}.invertScrollDirection {value}
{{moduleDescriptions[module]}}
Invert scroll direction

set » key cluster axis swapping

Swaps the X and Y axes of the key cluster's mini trackball, which can be useful because it's easier to roll the mini trackball along the horizontal axis with the thumb. This setting is available for all modules, but we only recommend using it with the key cluster.

Syntax is set module.{module}.swapAxes {value}

set » touchpad pinch-to-zoom mode

Controls the behavior of the touchpad's pinch-to-zoom gesture.

Syntax is set module.touchpad.pinchZoomMode {navigationMode}
Touchpad pinch-to-zoom mode

set » module navigation modes

UHK modules support the following navigation modes, which are mapped by layer and module:

Syntax is set module.{moduleId}.navigationMode.{layerId} {navigationMode}
Layer {{moduleDescriptions[module]}}
{{layer}}

set » navigation mode action

Customize caret or media navigation mode behavior by binding directions to shortcuts or macros.

Syntax is set navigationModeAction.{mode}.{direction} {action}
Macro name example
{mode} :
{direction} :
set navigationModeAction.{{navigationModeActionMode}}.{{navigationModeActionDirection}} macro YourMacroName

Shortcut example
{shortcut} :              
{key} :
set navigationModeAction.{{navigationModeActionMode}}.{{navigationModeActionDirection}} keystroke {{getScancode()}}

set » modifier layer triggers

Controls whether modifier layers are triggered by the left, right, or either modifier.

Syntax is set modifierLayerTriggers.{layer} {modifiers}
Layer Modifier trigger
{{modifier}}

set » mouse key speeds

Except for axisSkew, these settings are already featured on Agent's "Mouse key speed" page, which should be used primarily. These settings are still useful for keymap-specific mouse key speed settings.

Syntax is set mouseKeys.{mode}.{property} {floatValue}
Pointer speed Scroll speed
{{prop.desc}}

set » diagonal speed compensation

By default, the mouse pointer is faster diagonally than horizontally or vertically when using the mouse keys. This setting slows down the pointer diagonally when the mouse keys are used, so its speed matches horizontal and vertical speeds.

Syntax is set diagonalSpeedCompensation {compensationEnabled}

set » sticky modifiers

This setting affects the behavior of shortcuts on non-base layers. For example, if Mod + d is mapped to Alt + Tab and Mod + d is pressed, Alt + Tab is triggered, then if d is released while Mod is still held, Alt is held, too; hence, the modifier is sticky.

Syntax is set stickyModifiers {stickyMode}

set » double tap timeout

Controls the double tap timeout for layer locking.

Syntax is set doubletapTimeout {timeout}

set » keystroke delay

Allows slowing down keyboard output. This setting is handy for lousily written RDP clients and other software which scans keys once a while and processes them in the wrong order if multiple keys have been pressed in between.

This setting adds a delay whenever a basic USB report is sent. During this delay, the key matrix is still scanned, and keys are debounced, but instead of activating, the keys are added into a queue to be replayed later.

Syntax is keystrokeDelay {delay}

set » chording delay

Allows triggering chorded shortcuts in arbitrary order. For example, if A + Ctrl is pressed instead of Ctrl + A, the keyboard will still send Ctrl + A if the two key presses follow within the specified time.

Syntax is set chordingDelay {delay}

set » enable/disable LEDs

Enable/disable all LEDs.

Syntax is set leds.enabled {ledStatus}

set » LED brightness

Set the brightness of all LEDs.

Syntax is set leds.brightness {brightness}

set » LED fade timeout

Set timeout, after which all LEDs fade out to save power until the next user interaction.

Syntax is set leds.fadeTimeout {timeout}
LED fade timeout

Extended macro commands

There are extended macro commands available besides the commands mentioned here, enabling numerous advanced features.

We plan to add the extended commands to this documentation.