KeyBindings
Entity → ceramic.KeyBindings (Class)
Implements: Component
Manages a collection of keyboard shortcut bindings.
KeyBindings provides a convenient way to define and manage multiple keyboard shortcuts in your application. It can be used standalone or as a component attached to other entities.
Features:
- Create keyboard shortcuts with modifier keys
- Automatically handle platform differences (Cmd vs Ctrl)
- Component interface for easy attachment to entities
- Global key state reset functionality
Example usage:
var bindings = new KeyBindings();
// Bind Ctrl+S (or Cmd+S on macOS)
bindings.bind([CMD_OR_CTRL, KEY(KeyCode.KEY_S)], () -> {
saveDocument();
});
// Bind Shift+Delete
bindings.bind([SHIFT, KEY(KeyCode.DELETE)], () -> {
permanentDelete();
});
// Attach as component
myEntity.component(new KeyBindings());
See: KeyBinding, KeyAcceleratorItem
Static Members
Instance Members
entity: Entity
initializerName: String
destroy(): Void
bind(accelerator: Array<Anonymous>, ?callback: Function): KeyBinding
Creates a new keyboard shortcut binding.
Name | Type | Default | Description |
---|---|---|---|
accelerator |
Array |
Array of keys that must be pressed together. Order doesn't matter for modifier keys. | |
callback |
Function | (optional) | Optional callback function to execute when triggered. Can also be attached later using binding.onTrigger(). |
Returns | Description |
---|---|
KeyBinding | The created KeyBinding instance |
new(): Void
Private Members
instances: Array<KeyBindings>
Tracks all active KeyBindings instances. Used for global operations like forceKeysUp().
bindings: Array<KeyBinding>
Array of KeyBinding instances managed by this KeyBindings.
bindAsComponent(): Void
Component interface implementation. Called when this KeyBindings is attached to an entity as a component.
Name | Type |
---|---|
entity |
Entity |
getEntity(): Entity
Returns |
---|
Entity |
Metadata
Name | Parameters |
---|---|
:build |
ceramic.macros.ComponentMacro.build() |
:autoBuild |
ceramic.macros.ComponentMacro.build() |
:build |
ceramic.macros.EntityMacro.buildForCompletion() |
:autoBuild |
ceramic.macros.EntityMacro.buildForCompletion() |
:build |
tracker.macros.EventsMacro.build() |
:autoBuild |
tracker.macros.EventsMacro.build() |