Get key in my webapp dos not work

I need to get a key in my web app. When I use the code in Safari I get the keyboard input without using a textbox for example. When I use the same code in a webapp, I didn’t get the keyboard event. How can I change this.

 document.addEventListener('keydown', function(event) {
    if (event.keyCode == 69) {
    if (event.keyCode == 86) {
 }, true);
End JavaScript



Are you running on a device without a keyboard? In that case, ‘keydown’ does not happen.

Try using ‘touchstart’.

No, I use a bluetooth keyboard.

Did you try touchstart? I have no idea whether a BT keyboard connected to a touch screen device will actually create a keydown event.

Touchstart does not work with keyboard events. A BT Keyboard works fine, but only in browser mode.