0

we have implemented an image gallery with ion-slides (ionic 4) which in turn utilizes swiperjs.

For some reason I can not make it listen to keyboard events, it feels like the events are cought somwhere under the hood. This is my code in a nutshell:

<ion-slides #slides[options]="sliderOptions" (keyup)="handleKeyEvent($event)" >
   <ion-slide *ngFor="let slide of slideObjects; let i = index">
      <img [src]="slide.image.src" />
   </ion-slide>
</ion-slides>

Anybody knows how I can add keyboard navigation via the arrowLeft and arrowRight key?

Andreas
  • 1,691
  • 1
  • 15
  • 34
  • ionslides din't have any keyUp Method. You can listen to keyUp in other way and slide you images. Check this for Reference. https://stackoverflow.com/a/57410843/5909026 – Najam Us Saqib Aug 18 '21 at 07:07
  • Hi @Najam, this clickhandler with next slides I have already implemented and it works well, but the keyboard listener is not firing on any element for me. On a second thought, maybe I need to have a global service, which catches this keyup events on the document and then the slide component is simply subscribing to it? – Andreas Aug 18 '21 at 09:47
  • 1
    Exactly, That what I was about to propose to you. Make a service for Keyboard events and subscribe to it. – Najam Us Saqib Aug 18 '21 at 10:07

0 Answers0