0

Hey guys so I currently have an input form and would like to set showTag to false when pressing any other button besides enter. For example, after I press delete button or the letter q I would like the showTag boolean to be set to false. Is there any way to do this? Thanks!

<input type="text" v-model="msg" class="form-control m-0" placeholder="Filter by tag" @keyup.enter= "showTag=true" />

1 Answer 1

3

I mean, you could just handle all keyups, and check for the key code, since the passed event should be a regular javascript event like any other.

<input type="text" v-model="msg" class="form-control m-0" placeholder="Filter by tag" @keyup="onKeyup" />

...

methods: {
    onKeyup(event) {
        showTag = (event.which == 13 || event.keyCode == 13)
    },
},
Sign up to request clarification or add additional context in comments.

1 Comment

If you don't have to support older browsers, event.key === "Enter" is more expressive.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.