To detect enter press I'm using simple solution:
if (e.keyCode == 13) {
// do something
}
On desktop it works properly anywhere. On tablet, smartphone - too - but, if it comes to textarea this doesn't work.
It became a problem since few last chrome updates.
So, when you press enter from mobile you see just new line "\n", but no function execution.
So, how to detect enter on textarea on mobile devices on latest chrome version?
if like me you are using react, onKeyPress={e => e.key}
works.
e.key
returns "Enter" on browser and mobile
e.code
returns "Enter" on browser only
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