Keyboard shortcuts
The workspace runs a WindowCommand for each shortcut. workspace.RunCommand(command) runs the same commands from code.
| Command | Default keys | Action |
|---|---|---|
NextWindow |
Ctrl+Tab, Ctrl+F6 | Focus the bottom-most window. Repeat to visit every window. |
PreviousWindow |
Ctrl+Shift+Tab, Ctrl+Shift+F6 | Go back to the previous window. |
CloseWindow |
Ctrl+W, Ctrl+F4 | Close the focused window. A tab group closes with all its tabs. |
ToggleMinimize |
Ctrl+M | Minimize the focused window, or restore it. |
ToggleMaximize |
F11 | Maximize the focused window, or restore it. |
MoveLeft, MoveRight, MoveUp, MoveDown |
Ctrl+Arrows | Move the focused window by keyboard-step pixels. It stays in the viewport. |
ResizeNarrower, ResizeWider, ResizeShorter, ResizeTaller |
Ctrl+Shift+Arrows | Move the right or bottom edge by keyboard-step pixels, within the minimum size and the viewport. |
Move and resize do nothing on a minimized or maximized window.
With the Input System package
When the com.unity.inputsystem package is installed and the active input handler includes it, the shortcuts are Input System actions:
- The workspace uses the actions in the
UIToolboxmap (Workspace.INPUT_ACTION_MAP) of itsInputActionsasset. Each action with the name of aWindowCommandruns that command. A missing action has no shortcut. - With no asset assigned, the workspace uses the default asset
Assets/UIToolbox/Runtime/Resources/UIToolbox/ToolboxInputActions.inputactions. - To change the keys, copy the default asset, edit the bindings, and assign the copy:
- UXML:
<UIToolbox.Workspace input-actions="project://database/Assets/MyShortcuts.inputactions" /> - Code:
workspace.InputActions = myAsset;
- UXML:
- The workspace enables the map and does not disable it. Other workspaces can share one asset.
- A held move or resize key repeats after 400 ms, every 50 ms.
- A binding runs only when the held modifier keys are the ones it names. Ctrl+Shift+Tab runs
PreviousWindowand not the Ctrl+Tab binding ofNextWindow. - The default asset has no Cmd bindings. Add them to your copy for macOS.
- Editor panels (EditorWindows) do not use the actions. They use the fixed keys below.
Players can rebind with the standard Input System APIs on workspace.ActiveInputActionMap:
var action = workspace.ActiveInputActionMap!.FindAction(nameof(WindowCommand.CloseWindow));
action.Disable();
action.PerformInteractiveRebinding(bindingIndex).OnComplete(op => { op.Dispose(); action.Enable(); }).Start();
// Save and load the player's keys.
PlayerPrefs.SetString("tb-keys", workspace.ActiveInputActionMap.asset.SaveBindingOverridesAsJson());
workspace.ActiveInputActionMap.asset.LoadBindingOverridesFromJson(PlayerPrefs.GetString("tb-keys"));
ActiveInputActionMap is null until the workspace attaches to a runtime panel, and when the asset has no UIToolbox map. With no UIToolbox map, the workspace logs a warning and uses the fixed keys.
Gamepad
The default asset also has gamepad bindings:
| Command | Gamepad |
|---|---|
NextWindow, PreviousWindow |
Right shoulder, left shoulder |
CloseWindow |
View (select) |
ToggleMinimize |
Right stick press |
ToggleMaximize |
Y (north button) |
| Move | Right stick |
| Resize | Left trigger + right stick |
- The left trigger is a modifier: while it is held, the right stick only resizes.
- A gamepad has no pointer to give the workspace focus. When nothing in the panel has keyboard focus, the first gamepad command focuses the workspace.
- The D-pad and the left stick move keyboard focus between controls, and A clicks the focused control. UI Toolkit does this through the
UImap of the project-wide actions, not the workspace.
Focus and the focus ring
NextWindowandPreviousWindowmove keyboard focus to the first control of the new window, or to the workspace when the window has no control. The user then navigates the controls of that window.- Keyboard focus that enters a window focuses that window and brings it to front, as a click does.
- While the user navigates with keys or a gamepad, the workspace has the class
tb-workspace--navigating(Workspace.NAVIGATING_CLASS). The theme then shows a focus ring on the focused button, toggle, slider, list or scroll view. A pointer press removes the class, so a mouse user sees no ring.
Without the Input System package
The workspace reads the default keys from UI Toolkit KeyDownEvent. These keys are fixed. On macOS, Cmd replaces Ctrl.
Rules for both
- The shortcuts act only while UI Toolkit keyboard focus is in the workspace. The workspace is
focusable, so a click on a window or on empty workspace space gives it focus. ItstabIndexis -1, so Tab and the D-pad skip it. A focused control inside a window, such as aTextField, also counts. - Move and resize do nothing while a text field has focus, because the text field uses the arrow keys.
- A window that opens or gets focus from code does not take keyboard focus. Call
workspace.Focus()when the keys must work at once.NextWindowandPreviousWindoware the exception: they move keyboard focus into the new window. - Dock windows and hidden tabs are not in the Ctrl+Tab order. A tab group counts as one window.
- Set
keyboard-shortcuts="false"when the application uses these keys for something else.RunCommandstays available for your own bindings.