Here is my fiddle: DEMO
There is a button called "fb-send", which has to get clicked on key press on "enter" in the input field. How to achieve this?
<input @keyup.enter="" placeholder="Reply here" class="fb-comment-input" />
<i class="material-icons fb-button-right fb-send">⇨</i>
Any help would be much appreciated. Thank you.
To trigger a click button on ENTER key, We can use any of the keyup(), keydown() and keypress() events of jQuery. keyup(): This event occurs when a keyboard key is released. The method either triggers the keyup event, or to run a function when a keyup event occurs.
key # The key special attribute is primarily used as a hint for Vue's virtual DOM algorithm to identify vnodes when diffing the new list of nodes against the old list. Without keys, Vue uses an algorithm that minimizes element movement and tries to patch/reuse elements of the same type in-place as much as possible.
Vue has a convenient shorthand for v-on : the @ symbol. For example, @click is functionally equivalent to v-on:click .
You can also call method for fb_send directly on input field:
@keyup.enter="enterClicked()"
<Input v-model="value1" size="large" placeholder="large size" @keyup.enter.native="search"></Input>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With