From 23ad0338cb8690e33745eda767738f9138495e56 Mon Sep 17 00:00:00 2001 From: Antonio Laguna Date: Thu, 2 Mar 2017 09:43:08 +0100 Subject: [PATCH] Preventing navigation with keys if user using inputs Fixes #50 --- src/js/plugins/keyboard.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/js/plugins/keyboard.js b/src/js/plugins/keyboard.js index ce199f5..f8b5d61 100644 --- a/src/js/plugins/keyboard.js +++ b/src/js/plugins/keyboard.js @@ -25,6 +25,18 @@ export default class Keyboard { let method; let argument; + // Check if there's a focused element that might use the keyboard. + if (document.activeElement) { + const isContentEditable = document.activeElement + .contentEditable !== 'inherit'; + const isInput = ['INPUT', 'SELECT', 'OPTION', 'TEXTAREA'] + .indexOf(document.activeElement.tagName) > -1; + + if (isInput || isContentEditable) { + return; + } + } + switch (event.which) { case Keys.AV_PAGE: case Keys.SPACE: