mujoco icon indicating copy to clipboard operation
mujoco copied to clipboard

Add option to disable keyboard shortcuts in viewer

Open Shivam-Bhardwaj opened this issue 10 months ago • 1 comments

Summary

  • Add handle_keyboard parameter to launch() and launch_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: Add keyboard_ui flag
  • simulate/simulate.cc: Check flag before processing keyboard events
  • python/mujoco/simulate.cc: Expose keyboard_ui property in Python bindings
  • python/mujoco/viewer.py: Add handle_keyboard parameter 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 pyink and isort for style compliance
  • [ ] Manual testing with passive viewer (requires display)

Shivam-Bhardwaj avatar Jan 21 '26 04:01 Shivam-Bhardwaj

Hey, any update for this very helpful PR?

andreh1111 avatar Jun 10 '26 21:06 andreh1111