Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

111
Vistas
Swiper keyboard custom keys

I have a horizontal Swiper and keyboard enabled, which means I can swipe using left and right keys. But I want to be able to swipe using top and bottom keys as well. I wrote this script, but it doesn't work, does anyone have an idea why?

$(document).ready(function() {

  var swiper = new Swiper('.swiper', {
    direction: 'horizontal',
    slidesPerView: 1,
    speed: 600,
    effect: 'fade',
    keyboard: {
      enabled: true,
    },
  });

  swiper.addEventListener("keydown", function(e) {
    if (e.key == 38) {
      swiper.slidePrev();
    }
    if (e.key == 40) {
      swiper.slideNext();
    }
  });

});

I also read this documentation, maybe this is the easier way to assign custom keys, but I have no idea how to use it.

enter image description here

about 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

You can use keyPress event with swiper.on method, like it's described here

Example:

swiper.on("keyPress", (swiper, keyCode) => {
  switch (keyCode) {
    case 38:
      swiper.slidePrev();
      break;
    case 40:
      swiper.slideNext();
      break;
  }
});
about 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda