keyborg 2.0.0 → 2.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/Keyborg.d.ts CHANGED
@@ -33,7 +33,7 @@ export declare class KeyborgState {
33
33
  declare class KeyborgCore implements Disposable {
34
34
  readonly id: string;
35
35
  private _win?;
36
- private _isMouseUsed;
36
+ private _isMouseUsedTimer;
37
37
  private _dismissTimer;
38
38
  private _triggerKeys?;
39
39
  private _dismissKeys?;
package/dist/index.js CHANGED
@@ -244,11 +244,13 @@ const _state = /*#__PURE__*/new KeyborgState();
244
244
 
245
245
  class KeyborgCore {
246
246
  constructor(win, props) {
247
- this._isMouseUsed = false;
248
-
249
247
  this._onFocusIn = e => {
250
- if (this._isMouseUsed) {
251
- this._isMouseUsed = false;
248
+ // When the focus is moved not programmatically and without keydown events,
249
+ // it is likely that the focus is moved by screen reader (as it might swallow
250
+ // the events when the screen reader shortcuts are used). The screen reader
251
+ // usage is keyboard navigation.
252
+ if (this._isMouseUsedTimer) {
253
+ // There was a mouse event recently.
252
254
  return;
253
255
  }
254
256
 
@@ -278,7 +280,17 @@ class KeyborgCore {
278
280
  return;
279
281
  }
280
282
 
281
- this._isMouseUsed = true;
283
+ const win = this._win;
284
+
285
+ if (win) {
286
+ if (this._isMouseUsedTimer) {
287
+ win.clearTimeout(this._isMouseUsedTimer);
288
+ }
289
+
290
+ this._isMouseUsedTimer = win.setTimeout(() => {
291
+ delete this._isMouseUsedTimer;
292
+ }, 1000); // Keeping the indication of the mouse usage for some time.
293
+ }
282
294
 
283
295
  _state.setVal(false);
284
296
  };
@@ -330,6 +342,11 @@ class KeyborgCore {
330
342
  const win = this._win;
331
343
 
332
344
  if (win) {
345
+ if (this._isMouseUsedTimer) {
346
+ win.clearTimeout(this._isMouseUsedTimer);
347
+ this._isMouseUsedTimer = undefined;
348
+ }
349
+
333
350
  if (this._dismissTimer) {
334
351
  win.clearTimeout(this._dismissTimer);
335
352
  this._dismissTimer = undefined;
@@ -505,7 +522,7 @@ function disposeKeyborg(instance) {
505
522
  * Copyright (c) Microsoft Corporation. All rights reserved.
506
523
  * Licensed under the MIT License.
507
524
  */
508
- const version = "2.0.0";
525
+ const version = "2.1.0";
509
526
 
510
527
  exports.KEYBORG_FOCUSIN = KEYBORG_FOCUSIN;
511
528
  exports.Keyborg = Keyborg;
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -240,11 +240,13 @@ const _state = /*#__PURE__*/new KeyborgState();
240
240
 
241
241
  class KeyborgCore {
242
242
  constructor(win, props) {
243
- this._isMouseUsed = false;
244
-
245
243
  this._onFocusIn = e => {
246
- if (this._isMouseUsed) {
247
- this._isMouseUsed = false;
244
+ // When the focus is moved not programmatically and without keydown events,
245
+ // it is likely that the focus is moved by screen reader (as it might swallow
246
+ // the events when the screen reader shortcuts are used). The screen reader
247
+ // usage is keyboard navigation.
248
+ if (this._isMouseUsedTimer) {
249
+ // There was a mouse event recently.
248
250
  return;
249
251
  }
250
252
 
@@ -274,7 +276,17 @@ class KeyborgCore {
274
276
  return;
275
277
  }
276
278
 
277
- this._isMouseUsed = true;
279
+ const win = this._win;
280
+
281
+ if (win) {
282
+ if (this._isMouseUsedTimer) {
283
+ win.clearTimeout(this._isMouseUsedTimer);
284
+ }
285
+
286
+ this._isMouseUsedTimer = win.setTimeout(() => {
287
+ delete this._isMouseUsedTimer;
288
+ }, 1000); // Keeping the indication of the mouse usage for some time.
289
+ }
278
290
 
279
291
  _state.setVal(false);
280
292
  };
@@ -326,6 +338,11 @@ class KeyborgCore {
326
338
  const win = this._win;
327
339
 
328
340
  if (win) {
341
+ if (this._isMouseUsedTimer) {
342
+ win.clearTimeout(this._isMouseUsedTimer);
343
+ this._isMouseUsedTimer = undefined;
344
+ }
345
+
329
346
  if (this._dismissTimer) {
330
347
  win.clearTimeout(this._dismissTimer);
331
348
  this._dismissTimer = undefined;
@@ -501,7 +518,7 @@ function disposeKeyborg(instance) {
501
518
  * Copyright (c) Microsoft Corporation. All rights reserved.
502
519
  * Licensed under the MIT License.
503
520
  */
504
- const version = "2.0.0";
521
+ const version = "2.1.0";
505
522
 
506
523
  export { KEYBORG_FOCUSIN, Keyborg, createKeyborg, disposeKeyborg, getLastFocusedProgrammatically, nativeFocus, version };
507
524
  //# sourceMappingURL=keyborg.esm.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"keyborg.esm.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"keyborg.esm.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "keyborg",
3
- "version": "2.0.0",
3
+ "version": "2.1.0",
4
4
  "description": "Keyboard Navigation Detection for Web",
5
5
  "author": "Marat Abdullin <marata@microsoft.com>",
6
6
  "license": "MIT",