Javascript enter key pressed event alternative for mobile site
I just checked on android, when you type something and press "Go" (enter alternative?) it will trigger an event and the key code is actually 13 so the same as Enter on desktop keyboards.
Edit:
I'd suggest debugging the code and checking whether the submit is actually triggered but maybe the key code isn't always 13? Just guessing..
Edit2:
Test this code on your mobile. When I press "Go" the input value changes to "sent!" which proves that it works.
Why not use onblur
in combination with enter key? If one can press enter, it'll work as is. If one can't, they'll just leave input and then onblur
will do work.
I made it with wrapping in a form add onsubmit
then preventDefault
. (@submit.prevent
in Vue, actually.)
There doesn't really need to be an enter button, only just form and input.
form.field.m-sm.px-md(@submit.prevent="onSearch") .control.has-icons-right input.input.is-rounded(type="search" placeholder="Search" v-model="q") span.icon.is-right fa(icon="search")