iOS Badge Login

I've been working on an application using a bluetooth badge reader made by Serialio. I have it now working fine authenticating via the IDP using the badge authentication feature in Windows. However, the vendor and I have now ran into an issue getting it to work in iOS and was wondering if anyone has any suggestions. From what I've been told, the reason it is currently not working is due to the fact that Apple requires the user to tap to gain focus of a page, ect.. The potential workaround I'm trialing is using a browser made by Serialio called (iScanBrowser) that allows for custom web form rules to be executed. The way it is setup is that when the browser detects the login screen, the scanner can scan the badge and then run a custom JScript to post the scan data to the page. We can't get the JScript to work and the vendor is indicating that unless the webpage had a known field that it can post the data to, it isn't going to work. I've posted the script that is trying to run. Any feedback or suggestions are welcome.

function iSB_OnNewScan(scan) {
    for (let character of scan) { 
        let ev = new KeyboardEvent("keydown", { key: character });
        document.dispatchEvent(ev);
    }
    let ev = new KeyboardEvent("keypress", { keyCode: 13 });
    document.dispatchEvent(ev);
    return true;
}

I answered my own question. "keydown" needed to be changed to "keypress".