onKeyPress: event.key on mobile: "Unidentified"

I have an input box that uses an onKeyPress event. I am able to successfully receive the key that is pressed when using my Laptop. On my mobile device this is however not working. I looked at the console log events via remote debugging for android and got the following result. The key is unidentified.

Can you post your code?

export function input1_keyPress(event) {
    let key = event.key;
    console.log(key);
}

I think that this is probably not a code error rather a bug on wix side. The code works perfectly on all devices except for mobile phones with a touch screen.

Yes. I don’t see any issue with the code. Maybe you should ask Wix Support.

Have you tried changing the code so that it runs when the enter button is pressed?

$w(" #input1 ").onKeyPress((event, $w) => {
if (event.key === “Enter”) {
or
export function input1_keyPress(event, $w)
{ if (event.key === “Enter”) {

It might just be something simple like the key not being recognised on mobile devices yet working on pc/laptops etc with a physical keyboard.

Check key from KeyboardEvent.
https://www.wix.com/corvid/reference/$w.KeyboardEvent.html#key

Another option if you can’t get this to work, is to have an onClick event handler for mobile devices instead using Wix Window formFactor.
https://www.wix.com/corvid/reference/wix-window.html#formFactor
https://support.wix.com/en/article/corvid-writing-code-that-only-runs-on-mobile-devices
https://support.wix.com/en/article/corvid-tutorial-displaying-elements-in-mobile-only

Hi, thanks for the tip. It is still not working, I guess this is an external bug.

Hey Leon,

For it to work you have to use onKeypress not onInput
:slight_smile:

DJ bon26