Create the following html-page:
<textarea id="code" rows="10"></textarea>
<script>
document.onkeydown = function(event) {
alert(event.keyCode);
}
</script>
Open it on Mobile Safari (on a simulator or on a device with keyboard), tap on textarea to start editing. And now press any arrow key - event won't fire.
How to detect key down for arrow keys?
P.S. Related issue on Apple Bug Report system: 13243285
Keycode 13 is the Enter key.
To detect the arrow key when it is pressed, use onkeydown in JavaScript. The button has key code. As you know the left arrow key has the code 37. The up arrow key has the code 38 and right has the 39 and down has 40.
code and event. key. The key property of the event object allows to get the character, while the code property of the event object allows to get the “physical key code”. For instance, the same key Z can be pressed with or without Shift .
Official answer from Apple:
Thank you for contacting Apple Developer Technical Support (DTS). Our engineers have reviewed your request and have concluded that there is no supported way to achieve the desired functionality given the currently shipping system configurations.
$(selector).keydown(function(e){
if (e.keyCode == 37) {
alert( "left pressed" );
return false;
}
});
Character codes:
37 - left
38 - up
39 - right
40 - down
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With