I have an input where I listen for the keydown.space event. This technique works fine on the desktop, but the event isn't triggered on mobile. My HTML template looks like the following:
<input
type="text"
(keydown.space)="onAdd()"
(keydown.backspace)="onRemoveLast()"
>
So I need a way to listen to the space key event on the software keyboard of mobile phones.
What "mobile" did you test it on? If it's Android, like William Moore said, it may be an issue of Android not registering spacebar keypress as the standard 32.
Otherwise, you can try onkeypress + listening for the keycode on the JS side like so:
<input
type="text"
onkeypress="onAdd(event)"
(keydown.backspace)="onRemoveLast()"
>
function onAdd(event){
if (event.keyCode === 32) ...
}
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