{ if (e.key === 'Enter') go() }} />"
],
[
'named local handler',
`export function X() {
const onKeyDown = (e) => { if (e.key === 'Enter') submit() }
return
}`
],
[
'useCallback handler',
`export function X() {
const handleKeyDown = useCallback((e) => { if (e.key === 'Enter') submit() }, [])
return
}`
],
[
'keydown listener on an input ref',
`export function attach(inputRef) {
inputRef.current.addEventListener('keydown', (e) => { if (e.key === 'Enter') go() })
}`
],
[
'keydown listener on a created textarea',
`export function attach() {
const el = document.createElement('textarea')
el.addEventListener('keydown', (e) => { if (e.key === 'Enter') go() })
}`
]
]
const accepted = [
[
'shared guard inline',
"export const X = () =>
{ if (isImeCompositionKeyDown(e)) return; if (e.key === 'Enter') go() }} />"
],
[
'shared guard in a called helper',
`function ignoreIme(e) { return isImeOwnedKeyboardEvent(e) }
export function X() {
const onKeyDown = (e) => { if (ignoreIme(e)) return; if (e.key === 'Enter') go() }
return
}`
],
[
'gesture ownership guard',
"export const X = () =>
{ if (ime.ownsKeyDown(e)) return; if (e.key === 'Enter') go() }} />"
],
[
'element tracks composition itself',
"export const X = () =>
{ if (e.key === 'Enter') go() }} />"
],
[
'Input primitive',
"export const X = () =>
{ if (e.key === 'Enter') go() }} />"
],
[
'ImeTextarea',
"export const X = () =>
{ if (e.key === 'Enter') go() }} />"
],
[
'non-text input type',
'export const X = () => { if (e.key === "Enter") toggle() }} />'
],
[
'list row button',
"export const X = () =>