Catching screen keyboard entries in javascript on Android webview

In my (old but needed) webapp, I registered a keydown event on document (using jquery) to get which keys were pressed:

$(window).on('keydown', function(e) {
     console.log('e.key: ' + e.key);
     console.log('e.keyCode: ' + e.keyCode)
}

I need to bind it to the window because the mobile devices I use have a barcode scanner that emulate key presses. I want the barcode to be catched no matter where the cursor currently is. If the user needed to focus a special field before performing a barcode scan, usability would be ruined. This is why I cannot use the “input” event. “Keydown” worked for years.

Suddenly the scanners stopped working. Here I found why:

The W3C decided that virtual keyboards for whatever reason should fire keydown events, but should no longer submit the e.key or e.keyCode variables. By standard they should now send
keycode 229 and key “Unidentified”.

I haven’t found any way how to get my old usage case done. Any ideas how to catch a virtual keyboard press and get the code of the key pressed?