D
D
danilr2020-06-08 09:47:24
Vue.js
danilr, 2020-06-08 09:47:24

How to get the code of the key that was pressed in the Input Vue event?

<input ref="search"  :value="value" placeholder="Введите название книги"  @input="changeSearchName" @keyup="pressKey"
changeSearchName(event) {
          console.log(event.keyCode); // undefined
      },

In general, I need to pull something out of the Vue Input keyCode event.
I could get it in the keyup event (it is there), but if I drag it from there, then my logic gets more problems than without getting the code at all.
The task is that when entering the input, Ajax requests are made, I wanted to remove it so that when the backspace button is pressed, it is not requested, and if I receive the keyCode from keyUp, then since my value is stored in the vuex store, it seems to eat some letters and seems to slow down. And even if I only take keyPress from the keyup event and store it in the input event, then I have to enumerate the codes of all kinds of keys that do not lead to a change in the value of the input so that the Ajax request is not sent, say, from ctrl. This I explained why I need to take the keyCode from Input

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander, 2020-06-08
@UPSA

I saw something like this somewhere, but I can’t find it .... even here it seems.
They checked not keyXXX, but checked change with a delay and read the already typed text - "If the text has not been changed within 1 second after the changes, then send a request"

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question