Add option: listenToKeyEvents
Motivation and Context
Solves #409
-
useBuiltInControlsbinds mouse/drag and also keydown events - Applies the keydown listener to the entire window
The problem with this, is that enabling built in controls bulk enables all supported forms of controls, and the fact it applies it to the window context makes potential input elements being hijacked their ability to receive keydown events. Typically a textarea or text input would receive most key downs, except those caught by the viewer element.
Ideally another parameter shall be added, a dom element to apply the listener to. Applying it to the entire window is a bug, this PR does not address that, merely works around the issue by providing more granularity, allowing to keep non key down events and disabling keydowns. It is likely common for users to desire mouse/drag abilities, but not mind about the keyboard controls.
Description
Updates logic and README with listenToKeyEvents
- Adds
listenToKeyEventsoption and conditionals - Defaulting to true to maintain existing behavior
- Binds and add lister if
listenToKeyEventsis true
The changeset is backward compatible.
Steps to verify
Checkout the branch, using the demo:
-> Mouse, Drag, and key input should work.
Then also check:
- Set
listenToKeyEventsto false - Keep
useBuiltInControlsas is
-> The mouse/drag input should still work, but key events shall do nothing
any info ?