Add option: listenToKeyEvents #433
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Motivation and Context
Solves #409
useBuiltInControlsbinds mouse/drag and also keydown eventsThe 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
windowis 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
listenToKeyEventslistenToKeyEventsoption and conditionalslistenToKeyEventsis trueThe changeset is backward compatible.
Steps to verify
Checkout the branch, using the demo:
-> Mouse, Drag, and key input should work.
Then also check:
listenToKeyEventsto falseuseBuiltInControlsas is-> The mouse/drag input should still work, but key events shall do nothing