KeyboardMonitor
The KeyboardMonitor component captures keyboard events from the browser and sends them to your Python backend through WebSocket. This invisible component enables keyboard-based interactions in your Vuer applications.
This is ideal for:
- Building keyboard-controlled interfaces
- Implementing keyboard shortcuts
- Creating interactive applications with key bindings
- Capturing user input for text-based interactions
- Game controls and navigation
Basic Usage
A minimal example that monitors keyboard events:
Key Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
key | str | - | Unique identifier for the component |
enableKeyDown | bool | False | Enable monitoring of keydown events |
enableKeyUp | bool | False | Enable monitoring of keyup events |
enableKeyPress | bool | False | Enable monitoring of keypress events |
Note: At least one event type must be enabled for the component to be useful.
Event Types
The component sends three types of events to Python handlers:
KeyDown
Triggered when a key is pressed down. Repeats if the key is held.
KeyUp
Triggered when a key is released.
KeyPress
Triggered when a key that produces a character value is pressed.
Event Data Format
All keyboard events contain the following data in event.value:
Key vs Code
- key: The character or action represented (e.g.,
'a','A','Enter','ArrowUp') - code: The physical key location (e.g.,
'KeyA','Space','ArrowUp')
For most use cases, use key for character input and code for keyboard layout-independent bindings.
Notes
- The component is invisible and does not render any visual elements
- Keyboard events are only captured when the browser window has focus
- Some browser shortcuts (like Ctrl+T, Ctrl+W) cannot be prevented
- For text input, consider using HTML input elements instead
- The component automatically handles keyboard focus management
Related Components
- Hands - Hand tracking for VR/AR interactions
- MotionControllers - VR controller input
- Movable - Interactive object manipulation