Skip to content

Conversation

@hirako2000
Copy link

@hirako2000 hirako2000 commented Mar 10, 2025

Motivation and Context

Solves #409

  • useBuiltInControls binds 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 listenToKeyEvents option and conditionals
  • Defaulting to true to maintain existing behavior
  • Binds and add lister if listenToKeyEvents is 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 listenToKeyEvents to false
  • Keep useBuiltInControls as is

-> The mouse/drag input should still work, but key events shall do nothing

@igun997
Copy link

igun997 commented Oct 2, 2025

any info ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants