beforeinput event is not supported in Safari
OS: macOS Ubuntu 22.04 · Device: Desktop or Laptop Any · Browser: Safari 120.0 · Keyboard: US
Open case →Scenario
The beforeinput event, which is crucial for intercepting and modifying input before it's committed to the DOM, is not supported in Safari. This makes it difficult to implement custom input handling that works across all browsers.
The beforeinput event, which is crucial for intercepting and modifying input before it’s committed to the DOM, is not supported in Safari. This makes it difficult to implement custom input handling that works across all browsers.
Visual view of how this scenario connects to its concrete cases and environments. Nodes can be dragged and clicked.
Each row is a concrete case for this scenario, with a dedicated document and playground.
| Case | OS | Device | Browser | Keyboard | Status |
|---|---|---|---|---|---|
| ce-0043-beforeinput-not-supported | macOS Ubuntu 22.04 | Desktop or Laptop Any | Safari 120.0 | US | draft |
Open a case to see the detailed description and its dedicated playground.
OS: macOS Ubuntu 22.04 · Device: Desktop or Laptop Any · Browser: Safari 120.0 · Keyboard: US
Open case →Other scenarios that share similar tags or category.
Some browsers and keyboards emit duplicate composition-related input or beforeinput events—especially iOS Safari dictation paths and certain Android keyboards—so naive handlers that insert text on every input may double characters or corrupt state.
When composition ends, beforeinput may use inputType insertFromComposition or insertCompositionText. getTargetRanges() should describe the range to replace; on Safari (especially iOS) or with certain IMEs, ranges may be missing, wrong, or inconsistent with desktop Safari—breaking editors that rely on target ranges for transactions.
In Safari desktop, when preventDefault() is called on keydown or beforeinput events for insertParagraph (Enter key), the IME composition state becomes corrupted. Subsequent text input fails to trigger proper input events, causing characters to not be inserted or composition to malfunction.
On iOS, when using voice dictation to input text into contenteditable elements, the system may fire duplicate beforeinput and input events after the initial dictation completes. The text is split into words and events are re-fired, causing synchronization issues. Composition events do not fire during dictation, making it difficult to distinguish dictation from keyboard input.
On iOS Safari, input and beforeinput can fire with inputType 'insertText' multiple times (e.g. voice dictation) or with inputType undefined/null. Forcing re-render or changing selection during this flow desyncs the editor model from the DOM and can permanently break subsequent input.
Have questions, suggestions, or want to share your experience? Join the discussion below.