Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

nuna's avatar
Level 1

How to prevent this function from running when press enter?

onPress(e){
                if(e.keyCode == 13){
                   this.checkingNric(e.preventDefault());
                }
            },

I want to stop checkingNric from running when user presse enter key.Please help

0 likes
2 replies
rodrigo.pedra's avatar
Level 56

Not sure if I understood it well.

This will stop calling this.checkingNric() after the first time enter is pressed.

As you are using Vue, add the enterWasPressed: false variable to your component's data().

onPress(e){
    if(e.keyCode == 13){
        this.enterWasPressed = true;
    }

    if (! this.enterWasPressed) {
        this.checkingNric(e.preventDefault());
    }
},

Please or to participate in this conversation.