menu_bookDocumentation
Editor Shortcuts - s&box Editor Documentation
Editor Shortcuts
Custom keyboard shortcuts make your editor tools more efficient. Shortcuts can be bound globally or to specific widgets.
Creating a Static Shortcut
Register a shortcut that works anywhere in the editor:
CSHARP
[Shortcut( "mytool.do_something", "SHIFT+D" )]
public static void DoSomething()
{
// This runs when SHIFT+D is pressed
Log.Info( "Shortcut triggered!" );
}The first parameter is a unique identifier, the second is the key combination.
Creating a Widget Shortcut
Shortcuts can also be bound to specific widget contexts:
CSHARP
public class MyWidget : Widget
{
public MyWidget() : base( null )
{
// Add shortcut to this widget
AddShortcut( "mywidget.refresh", "F5", Refresh );
}
void Refresh()
{
// Called when F5 is pressed while this widget is focused
}
}Key Modifiers
Supported modifiers:
- CTRL — Control key
- SHIFT — Shift key
- ALT — Alt key
- Combinations like CTRL+SHIFT+S
Special Keys
Common special keys:
- F1 through F12 — Function keys
- TAB, SPACE, ENTER
- DELETE, BACKSPACE
- ESCAPE
- HOME, END, PAGEUP, PAGEDOWN
- Arrow keys: UP, DOWN, LEFT, RIGHT
Best Practices
- Use descriptive identifiers with namespaces
- Avoid conflicts with default editor shortcuts
- Document your shortcuts for users
- Provide alternative access (buttons) for discoverability
Was this helpful?