ngx-bootstrap icon indicating copy to clipboard operation
ngx-bootstrap copied to clipboard

How do I stop changing slide on hitting SPACE key?

Open yashwp opened this issue 5 years ago • 3 comments

Description: I see you have a feature for Keyboard interaction. I want to stop the changing of the slide on hitting SPACE or ENTER key. How do I stop this?

As of now, I've to stop the propagation by

@HostListener('keydown', ['$event'])
  stopBubbling(event) {
    event.stopPropagation();
  }

PS- I'm not keen to use a workaround, which by block the space key

yashwp avatar Nov 13 '19 07:11 yashwp

I've been trying to do the same with no success. Has anyone gone any further or found another workaround?

eplata31 avatar Aug 26 '20 23:08 eplata31

I use input in the slide and prevent writing 'space' char in the input

AhmadPirzargar avatar Feb 03 '21 10:02 AhmadPirzargar

In case anyone still needs to acomplish this in 2023, here is how I did it by overriding the ngx-carousel internal property keydownPress (I am not proud, but it worked)

 <carousel
        #carouselElementReference
        class="carousel top-controls"
        [interval]="0"
        [noPause]="false"
        [(activeSlide)]="activeSlideIndex"
      >

  @ViewChild('carouselElementReference') carouselElement: any; // #carouselElementReference

 constructor(){...}


  ngAfterViewInit() {
    this.disableSpaceKeyInCarousel();
  }

  disableSpaceKeyInCarousel() {
    if (!this.carouselElement) {
      return;
    }

    this.carouselElement.keydownPress = function(e) { console.log('keydown carousel disabled')}
  }

romuloctba avatar Nov 20 '23 12:11 romuloctba