From 499fff145dfd04162a8fab33913494206b4ce3e4 Mon Sep 17 00:00:00 2001 From: Matthew Petroff Date: Mon, 23 Oct 2017 19:15:11 -0400 Subject: [PATCH] Add option to disable keyboard controls. --- doc/json-config-parameters.md | 5 +++++ src/js/pannellum.js | 9 ++++++--- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/doc/json-config-parameters.md b/doc/json-config-parameters.md index f49d920..315d663 100644 --- a/doc/json-config-parameters.md +++ b/doc/json-config-parameters.md @@ -98,6 +98,11 @@ viewer is fullscreen. If set to `false`, mouse and touch dragging is disabled. Defaults to `true`. +### `disableKeyboardCtrl` (boolean) + +If set to `true`, keyboard controls are disabled. Defaults to `false`. + + ### `showFullscreenCtrl` (boolean) If set to `false`, the fullscreen control will not be displayed. Defaults to diff --git a/src/js/pannellum.js b/src/js/pannellum.js index 5698218..de0f266 100644 --- a/src/js/pannellum.js +++ b/src/js/pannellum.js @@ -101,6 +101,7 @@ var defaultConfig = { backgroundColor: [0, 0, 0], animationTimingFunction: timingFunction, draggable: true, + disableKeyboardCtrl: false, }; // Translatable / configurable strings @@ -472,9 +473,11 @@ function onImageLoad() { uiContainer.addEventListener('fullscreenchange', onFullScreenChange, false); window.addEventListener('resize', onDocumentResize, false); window.addEventListener('orientationchange', onDocumentResize, false); - container.addEventListener('keydown', onDocumentKeyPress, false); - container.addEventListener('keyup', onDocumentKeyUp, false); - container.addEventListener('blur', clearKeys, false); + if (!config.disableKeyboardCtrl) { + container.addEventListener('keydown', onDocumentKeyPress, false); + container.addEventListener('keyup', onDocumentKeyUp, false); + container.addEventListener('blur', clearKeys, false); + } document.addEventListener('mouseleave', onDocumentMouseUp, false); dragFix.addEventListener('touchstart', onDocumentTouchStart, false); dragFix.addEventListener('touchmove', onDocumentTouchMove, false);