์ผ€์ด์Šค ce-0251-mac-accent-menu-composition-en-ko ยท ์‹œ๋‚˜๋ฆฌ์˜ค scenario-mac-accent-menu-composition

Mac accent menu composition events inconsistent

OS: macOS 13+ ๊ธฐ๊ธฐ: Desktop (Mac) Any ๋ธŒ๋ผ์šฐ์ €: Safari 17+ ํ‚ค๋ณด๋“œ: English (QWERTY) ์ดˆ์•ˆ
compositionimemacosaccent-menukeyboard

ํ˜„์ƒ

On macOS, when using the accent menu to insert accented characters or special symbols, standard IME composition events do not fire consistently. This affects distinguishing accent menu input from IME input.

์žฌํ˜„ ์˜ˆ์‹œ

  1. Focus on contenteditable element.
  2. Use accent menu (hold vowel key + option) to enter special character (e.g., โ€˜รฉโ€™).
  3. Continue typing with regular keyboard.

๊ด€์ฐฐ๋œ ๋™์ž‘

  • compositionstart missing: compositionstart event may not fire when using accent menu
  • compositionupdate inconsistent: compositionupdate may not fire or fires at unexpected times
  • compositionend missing/delayed: compositionend may not fire or fires with delay
  • Difficult to distinguish: Hard to tell if user is using accent menu or full IME programmatically

์˜ˆ์ƒ ๋™์ž‘

  • Accent menu usage should trigger composition events consistently
  • Should be able to distinguish from regular keyboard input
  • Composition events should follow standard sequence

์ฐธ๊ณ ์‚ฌํ•ญ ๋ฐ ๊ฐ€๋Šฅํ•œ ํ•ด๊ฒฐ ๋ฐฉํ–ฅ

  • Use beforeinput inputType: Check inputType = 'insertCompositionText' to detect IME input
  • Track keyboard state: Monitor keydown/keyup events as fallback
  • Alternative state management: Use additional state flags
  • macOS specific understanding: Understand how accent menu works at system level

์ฝ”๋“œ ์˜ˆ์‹œ

const editor = document.querySelector('div[contenteditable]');
let isComposing = false;
let lastInputType = '';
let keyDownCount = 0;
let keyUpCount = 0;

editor.addEventListener('beforeinput', (e) => {
  lastInputType = e.inputType || '';
  if (e.inputType === 'insertCompositionText') {
    // IME composition
    isComposing = true;
  } else if (e.inputType === 'insertText') {
    // Regular keyboard input
    if (isComposing && lastInputType !== 'insertCompositionText') {
      // insertText without prior compositionstart = likely accent menu
      console.warn('Potential accent menu usage without composition events');
    }
  }
});

editor.addEventListener('compositionstart', () => {
  isComposing = true;
  console.log('Composition started');
});

editor.addEventListener('compositionupdate', (e) => {
  console.log('Composition update:', e.data);
});

editor.addEventListener('compositionend', () => {
  isComposing = false;
  console.log('Composition ended');
});

// Detect accent menu as alternative
editor.addEventListener('keydown', (e) => {
  keyDownCount++;
  
  const isAccentMenu = e.altKey || isVowelKey(e.key) || isLongKeyPress();
  
  if (isAccentMenu) {
    console.log('Potential accent menu usage detected');
  }
});

editor.addEventListener('keyup', (e) => {
  keyUpCount++;
});

function isVowelKey(key) {
  const vowels = ['a', 'e', 'i', 'o', 'u'];
  return vowels.includes(key.toLowerCase());
}

function isLongKeyPress() {
  return keyDownCount > keyUpCount + 1;
}

์ด ์‹œ๋‚˜๋ฆฌ์˜ค์˜ ๋ณ€ํ˜•

์ผ€์ด์Šค OS ๋ธŒ๋ผ์šฐ์ € ์ƒํƒœ
ce-0251-mac-accent-menu-composition-en-ko macOS 13+ Safari 17+ ์ดˆ์•ˆ
ce-0250-mac-accent-menu-composition-ko macOS 13+ Safari 17+ ์ดˆ์•ˆ

Playground for this case

Use the reported environment as a reference and record what happens in your environment while interacting with the editable area.

Reported environment
OS: macOS 13+
Device: Desktop (Mac) Any
Browser: Safari 17+
Keyboard: English (QWERTY)
Your environment
Sample HTML:
Event log
Use this log together with the case description when filing or updating an issue.
0 events
Interact with the editable area to see events here.