Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

214
Views
Why don't my Vue keyup event properties work?

I have the following code in Vue which is working for the click events but not or the keyboard events:

<span v-show="show" @click.prevent="backTo" @keyup.enter="backTo" @keyup.space="backTo">

I have the backTo() method set up to go to the previous page, but when I use the keyboard events it does nothing. When clicked it is working fine.

I placed an alert in the method to understand what it is doing, but on the keyboard event it does nothing and onmouseclick I get the alert.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

spans don't typically see keyboard events. Either change to a naturally editable element, or add tabindex="0" or add contenteditable=true

Vue.config.productionTip = false;

var app = new Vue({
  el: '#app',
  data: {
  },
  methods: {
    backTo() {
      alert('got here!');
    }
  }
})
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.17/vue.js"></script>
<div id="app">
  <span tabindex="0" @click.prevent="backTo" @keyup.enter="backTo" @keyup.space="backTo">Click on me to give me focus, then press space or enter</span>
</div>

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!