ngx-bootstrap
ngx-bootstrap copied to clipboard
How do I stop changing slide on hitting SPACE key?
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
I've been trying to do the same with no success. Has anyone gone any further or found another workaround?
I use input in the slide and prevent writing 'space' char in the input
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')}
}