How to trigger Enter key event inside a method?

vue-core

#1

I have this:

<p @click="code">Click</p>

In code() method, I want to do some work, and in the last step I want to trigger the Enter key event.

How to achieve this?


#2

You can create your Enter event function as a method and reuse it in your code() function. Perhaps you can show how you register your Enter event first so we have clearer idea on how you trigger your enter event.


#3

Thank you @chenxeed
Here is a link to the same question on StackOverflow with a live demo: https://stackoverflow.com/questions/55372562/how-to-trigger-the-enter-key-press-event-on-url-hash-modification