各种笔记 – Input events across browsers - the-dissidents/subtle GitHub Wiki

Note: beforeinput (omitted here for conciseness) is always fired just before input and has the same event data as the latter.

Input a lower-case a

macOS / Chrome

  • keydown – key: a code: KeyA
  • input – inputType: insertText, data: a
  • keyup – key: a code: KeyA

macOS / Safari

The same.

Pressing Backspace

macOS / Chrome

  • keydown – key: Backspace code: Backspace
  • input – inputType: deleteContentBackward
  • keyup – key: Backspace code: Backspace

macOS / Safari

The same.

Input œ by Option+Q

macOS / Chrome

  • keydown – key: Alt code: AltLeft
  • keydown – key: œ code: KeyQ
  • input – inputType: insertText, data: œ

then, if first releasing Q:

  • keyup – key: œ code: KeyQ
  • keyup – key: Alt code: AltLeft

if first releasing Option:

  • keyup – key: Alt code: AltLeft
  • keyup – key: q code: KeyQ

macOS / Safari

The same.

Input by IME composition

macOS / Chrome

  • keydown – key: h code: KeyH
  • compositionstart – data: empty string
  • input – isComposing: true, inputType: insertCompositionText, data: h
  • keyup – key: h code: KeyH
  • keydown – key: 2 code: Digit2
  • input – isComposing: true, inputType: insertCompositionText, data:
  • compositionend – data:
  • keyup – key: 2 code: Digit2

macOS / Safari

See: https://bugs.webkit.org/show_bug.cgi?id=165004 (bug report from 2016!)

  • compositionstart – data: empty string
  • input – isComposing: true, inputType: insertCompositionText, data: h
  • keydown – key: h code: KeyH
  • keyup – key: h code: KeyH
  • input – isComposing: true, inputType: deleteCompositionText
  • input – isComposing: true, inputType: insertFromComposition, data:
  • compositionend – data:
  • keydown – key: 2 code: Digit2
  • keyup – key: 2 code: Digit2

Input   (fullwidth space) by Option+Space while under IME

macOS / Chrome

  • keydown – key: Alt code: AltLeft
  • keydown – key:   (fullwidth) code: Space
  • input – inputType: insertText, data:   (fullwidth)

then, if first releasing Space:

  • keyup – key:   (fullwidth) code: Space
  • keyup – key: Alt code: AltLeft

if first releasing Option:

  • keyup – key: Alt code: AltLeft
  • keyup – key: (halfwidth) code: Space

macOS / Safari

  • keydown – key: Alt code: AltLeft
  • input – inputType: insertText, data:   (fullwidth)
  • keydown – key:   (fullwidth) code: Space

then, if first releasing Space:

  • keyup – key:   (halfwidth) code: Space
  • keyup – key: Alt code: AltLeft

if first releasing Option:

  • keyup – key: Alt code: AltLeft
  • keyup – key:   (halfwidth) code: Space