Keyboard extension input auto enter

23 Views Asked by At

I'm developing a keyboard extension to have it custom for my distinct host app. The keyboard is connected with hardware barcode scanner.

I have problem to auto 'send' the form when the barcode read. So, if I have other string (barcode) combine with the ("\r"), this will not trigger the auto send.

func performBarcodeScan(barcode: String, scanner: String) {
        textDocumentProxy.insertText(barcode+"\r")
}

But, I tried with this situation where I already type some string input in the field and have only ("\r") as below, that will work:

func performBarcodeScan(barcode: String, scanner: String) {
        textDocumentProxy.insertText("\r")
}

Having the insertText twice to separate the string also does not work.

Having dummy changes on input view as below will sometimes make it work, sometimes not:

barcode = barcode + "1"
textDocumentProxy.insertText(barcode)
textDocumentProxy.deleteBackward(times: 1)
textDocumentProxy.insertText("\r")

How can I solve this?

0

There are 0 best solutions below