Add safety check to mjui_event.
Add safety check to mjui_event.

PiperOrigin-RevId: 471809554
Change-Id: I563cac24781a9da6f7aa8313c9ea0b15c7b30903

deepmind/mujoco,deepmind/mujoco,deepmind/mujoco,deepmind/mujoco,deepmind/mujoco