I have this unicode converter opensource application in which I'm using Quill. The issue right now is, the application works on PC browser but not on mobile. Reason is event.key passes Unidentified on mobile.
My attempt was to use catch the input event, when the pressed key can be converted, preventDefault() and insert the text manually to the editor based on event.data property. However, Quill writes the data on to the editor on keydown which needs to be stopped.
Current implementation:
@HostListener('keydown', ['$event'])
onKeyPress(event: KeyboardEvent) {
this.editorService.onKeyDown.emit(event)
}
convert(event: KeyboardEvent): void {
if (!this.converting) return
/*
* keydown event passes keys like backspace as "Backspace" this is to
* try to eliminate those keys being typed literally on to the editor
*/
if (event.key.length > 1) return
event.preventDefault()
const currentWord = this.editorComponent.getCurrentWord()
const rule = this.converter.convert(event.key, currentWord)
this.editorComponent.type(rule.result)
}
When I add a new event handler to input (to document), Quill already have typed the entered letter since keydown is emitted before input.
Is it possible to make it use input event to write stuff instead?