pespantelis/vue-typeahead

trap the delete event on typeahead component

siavash13 opened this issue · 1 comments

I have used typeahead as component in my project and so far it's been useful, now I need to trap the delete and backspace buttons when clicked, but I have no idea how to trap these events in typeahead component could you please help me through this issue?

Vue.js captures both Delete & Backspace keys by using the .delete key modifier [#ref].

So, you could try something like this:

<template>
  <input type="text" @keydown.delete="onDelete"/>
</template>

<script>
export default {
  methods: {
    onDelete (event) {
      if (event.key === 'Delete') {
        console.log('Delete')
      } else {
        console.log('Backspace')
      }
    }
  }
}
</script>