lil-gui
lil-gui copied to clipboard
captureKeys flag
Adds a captureKeys
flag to GUI's constructor, which is true by default. If this is false, GUI will not call stopPropagation()
on key events that originate from within the GUI. The user must then manage event propagation manually using something like the following:
const gui = new GUI( { captureKeys: false } );
window.addEventListener( 'keydown', e => {
if ( gui.domElement.contains( e.target ) ) {
// I'm typing in the GUI.
} else if ( e.code === 'Space' ) {
jump();
}
});
[!WARNING]
As of this change, folder titles will capture key events by default. This is different than0.19.2
.
The reason for this change is to have uniform behavior between Controllers and folder titles: they both respect captureKeys
the same way. Of course, you can disable this behavior with { captureKeys: false }
, but then you must manage all events yourself as shown above.
For tests: expanded the browser shim to simulate event propagation.