J
J
jazzus2019-01-14 03:16:29
Vue.js
jazzus, 2019-01-14 03:16:29

How to run a method on key press?

There is a form field input in a child component (a form within a form)

<div class="form-group">
              <label for="website">Вебсайт</label>
              <input v-model="object.website" class="form-control" type="text" name="website" id="website" placeholder="Вебсайт" @onkeyup="sendContacts()">
            </div>

When entering from the keyboard, I want to pass the values ​​​​to the parent for the sending post
sendContacts() {
        this.$emit('send_contacts', this.object);
      },

When clicking on the selects, everything is OK - the object is transferred, but when the keys are pressed, it does not want to
Try these 3
onkeydown	реагирует на нажатие клавиши;
onkeypress	реагирует на нажатие клавиши;
onkeyup	реагирует на отпускание клавиши;

Answer the question

In order to leave comments, you need to log in

1 answer(s)
K
Konstantin Malyarov, 2019-01-14
@jazzus

@change="sendContacts()"

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question