mujoco
mujoco copied to clipboard
Add option to disable keyboard shortcuts in viewer
Summary
- Add
handle_keyboardparameter tolaunch()andlaunch_passive()functions - When set to
False, built-in keyboard shortcuts (e.g., 'W' for wireframe, space for pause) are disabled - Useful for robot teleoperation where keyboard inputs should be handled by user code
Closes #2953
Changes
simulate/simulate.h: Addkeyboard_uiflagsimulate/simulate.cc: Check flag before processing keyboard eventspython/mujoco/simulate.cc: Exposekeyboard_uiproperty in Python bindingspython/mujoco/viewer.py: Addhandle_keyboardparameter to launch functions
Example usage
# Disable keyboard shortcuts for teleoperation
viewer = mujoco.viewer.launch_passive(
model, data,
handle_keyboard=False, # Disable built-in shortcuts
key_callback=my_teleop_callback # Handle keys in user code
)
Test plan
- [x] Code follows existing patterns for
ui0_enable/ui1_enable - [x] Ran
pyinkandisortfor style compliance - [ ] Manual testing with passive viewer (requires display)
Hey, any update for this very helpful PR?