summaryrefslogtreecommitdiff
path: root/ext/mixed/js/environment.js
diff options
context:
space:
mode:
authortoasted-nutbread <toasted-nutbread@users.noreply.github.com>2020-09-08 10:53:41 -0400
committerGitHub <noreply@github.com>2020-09-08 10:53:41 -0400
commit36fc5abae543840484b3d8f7abff85f57de66ada (patch)
treed8ce5b59ca26e8b91957989a775cb75a76c3d44a /ext/mixed/js/environment.js
parent0a5e832dfddcc6184410e8836cc8dea030457486 (diff)
Modifier key refactor (#784)
* Add functions for getting keyboard key information * Use os + DocumentUtil to get modifier key names * Remove keyboard modifier info from environment info
Diffstat (limited to 'ext/mixed/js/environment.js')
-rw-r--r--ext/mixed/js/environment.js61
1 files changed, 1 insertions, 60 deletions
diff --git a/ext/mixed/js/environment.js b/ext/mixed/js/environment.js
index 1f4038d2..3ed9f5cf 100644
--- a/ext/mixed/js/environment.js
+++ b/ext/mixed/js/environment.js
@@ -33,11 +33,9 @@ class Environment {
async _loadEnvironmentInfo() {
const browser = await this._getBrowser();
const os = await this._getOperatingSystem();
- const modifierInfo = this._getModifierInfo(browser, os);
return {
browser,
- platform: {os},
- modifiers: modifierInfo
+ platform: {os}
};
}
@@ -91,61 +89,4 @@ class Environment {
return 'chrome';
}
}
-
- _getModifierInfo(browser, os) {
- let osKeys;
- let separator;
- switch (os) {
- case 'win':
- separator = ' + ';
- osKeys = [
- ['alt', 'Alt'],
- ['ctrl', 'Ctrl'],
- ['shift', 'Shift'],
- ['meta', 'Windows']
- ];
- break;
- case 'mac':
- separator = '';
- osKeys = [
- ['alt', '⌥'],
- ['ctrl', '⌃'],
- ['shift', '⇧'],
- ['meta', '⌘']
- ];
- break;
- case 'linux':
- case 'openbsd':
- case 'cros':
- case 'android':
- separator = ' + ';
- osKeys = [
- ['alt', 'Alt'],
- ['ctrl', 'Ctrl'],
- ['shift', 'Shift'],
- ['meta', 'Super']
- ];
- break;
- default: // 'unknown', etc
- separator = ' + ';
- osKeys = [
- ['alt', 'Alt'],
- ['ctrl', 'Ctrl'],
- ['shift', 'Shift'],
- ['meta', 'Meta']
- ];
- break;
- }
-
- const isFirefox = (browser === 'firefox' || browser === 'firefox-mobile');
- const keys = [];
-
- for (const [value, name] of osKeys) {
- // Firefox doesn't support event.metaKey on platforms other than macOS
- if (value === 'meta' && isFirefox && os !== 'mac') { continue; }
- keys.push({value, name});
- }
-
- return {keys, separator};
- }
}