| 1 |
// Copyright (c) Jupyter Development Team. |
| 2 |
// Distributed under the terms of the Modified BSD License. |
| 3 |
/*----------------------------------------------------------------------------- |
| 4 |
| Copyright (c) 2014-2017, PhosphorJS Contributors |
| 5 |
| |
| 6 |
| Distributed under the terms of the BSD 3-Clause License. |
| 7 |
| |
| 8 |
| The full license is in the file LICENSE, distributed with this software. |
| 9 |
|----------------------------------------------------------------------------*/ |
| 10 |
|
| 11 |
/** |
| 12 |
* The namespace for platform related utilities. |
| 13 |
*/ |
| 14 |
export namespace Platform { |
| 15 |
/** |
| 16 |
* A flag indicating whether the platform is Mac. |
| 17 |
*/ |
| 18 |
export const IS_MAC = !!navigator.platform.match(/Mac/i); |
| 19 |
|
| 20 |
/** |
| 21 |
* A flag indicating whether the platform is Windows. |
| 22 |
*/ |
| 23 |
export const IS_WIN = !!navigator.platform.match(/Win/i); |
| 24 |
|
| 25 |
/** |
| 26 |
* A flag indicating whether the browser is IE. |
| 27 |
*/ |
| 28 |
export const IS_IE = /Trident/.test(navigator.userAgent); |
| 29 |
|
| 30 |
/** |
| 31 |
* A flag indicating whether the browser is Edge. |
| 32 |
*/ |
| 33 |
export const IS_EDGE = /Edge/.test(navigator.userAgent); |
| 34 |
|
| 35 |
/** |
| 36 |
* Test whether the `accel` key is pressed. |
| 37 |
* |
| 38 |
* @param event - The keyboard or mouse event of interest. |
| 39 |
* |
| 40 |
* @returns Whether the `accel` key is pressed. |
| 41 |
* |
| 42 |
* #### Notes |
| 43 |
* On Mac the `accel` key is the command key. On all other |
| 44 |
* platforms the `accel` key is the control key. |
| 45 |
*/ |
| 46 |
export function accelKey(event: KeyboardEvent | MouseEvent): boolean { |
| 47 |
return IS_MAC ? event.metaKey : event.ctrlKey; |
| 48 |
} |
| 49 |
} |