[Vuejs]-How to prevent normal cursor behavior when pressing keys in a textarea

0👍

Use preventDefault on the keydown event instead of keyup.

document.querySelector('textarea').addEventListener('keydown', e => {
  if (e.key === 'ArrowDown' || e.key === 'ArrowUp') {
    e.preventDefault()
  }
})
<textarea>Hello, World! Hello, World! Hello, World! Hello, World! </textarea>

Leave a comment