From dcd99aa7d1cb8018a1378bc75053853e07edbfff Mon Sep 17 00:00:00 2001 From: Tanguy Krotoff Date: Wed, 15 Apr 2020 16:52:18 +0200 Subject: Replace event.which with event.key and event.button --- js/src/carousel.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'js/src/carousel.js') diff --git a/js/src/carousel.js b/js/src/carousel.js index a5451538c..93f896e53 100644 --- a/js/src/carousel.js +++ b/js/src/carousel.js @@ -33,8 +33,8 @@ const DATA_KEY = 'bs.carousel' const EVENT_KEY = `.${DATA_KEY}` const DATA_API_KEY = '.data-api' -const ARROW_LEFT_KEYCODE = 37 // KeyboardEvent.which value for left arrow key -const ARROW_RIGHT_KEYCODE = 39 // KeyboardEvent.which value for right arrow key +const ARROW_LEFT_KEY = 'ArrowLeft' +const ARROW_RIGHT_KEY = 'ArrowRight' const TOUCHEVENT_COMPAT_WAIT = 500 // Time for mouse compat events to fire after touch const SWIPE_THRESHOLD = 40 @@ -342,12 +342,12 @@ class Carousel { return } - switch (event.which) { - case ARROW_LEFT_KEYCODE: + switch (event.key) { + case ARROW_LEFT_KEY: event.preventDefault() this.prev() break - case ARROW_RIGHT_KEYCODE: + case ARROW_RIGHT_KEY: event.preventDefault() this.next() break -- cgit v1.2.3