From 8df5d4a8cda4117f6fd3c1fa8b2eb90ab3b96787 Mon Sep 17 00:00:00 2001 From: Adam Bradley Date: Wed, 22 Apr 2015 21:48:36 -0500 Subject: [PATCH] tab key only --- src/util/focus.js | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/src/util/focus.js b/src/util/focus.js index 3854d1d74e..6a18ef11ca 100644 --- a/src/util/focus.js +++ b/src/util/focus.js @@ -1,17 +1,22 @@ import {dom} from 'ionic2/util' +/* Focus Outline + * -------------------------------------------------- + * When a keydown event happens, from a tab key, then the + * 'key-input' class is added to the body element so focusable + * elements have an outline. On a mousedown or touchstart + * event then the 'key-input' class is removed. + */ + let isKeyInputEnabled = false -function keyDown() { - if (!isKeyInputEnabled) { +function keyDown(ev) { + if (!isKeyInputEnabled && ev.keyCode == 9) { isKeyInputEnabled = true dom.raf(enableKeyInput) } } -dom.ready().then(function() { - document.addEventListener('keydown', keyDown) -}) function enableKeyInput() { @@ -32,3 +37,7 @@ function pointerDown() { dom.raf(enableKeyInput) } + +dom.ready().then(function() { + document.addEventListener('keydown', keyDown) +})