UNPKG

@bitrix24/b24ui-nuxt

Version:

Bitrix24 UI-Kit for developing web applications REST API for NUXT & VUE

23 lines (22 loc) 596 B
export function useIMEGuard(callback) { let compositionJustEnded = false; function isComposing(event) { return event.isComposing || event.keyCode === 229; } function onKeydown(event) { if (compositionJustEnded || isComposing(event)) { return; } event.preventDefault(); callback(event); } let compositionEndTimer; function onCompositionEnd() { clearTimeout(compositionEndTimer); compositionJustEnded = true; compositionEndTimer = setTimeout(() => { compositionJustEnded = false; }, 50); } return { onKeydown, onCompositionEnd }; }