aboutsummaryrefslogtreecommitdiff
path: root/ext/mixed
diff options
context:
space:
mode:
Diffstat (limited to 'ext/mixed')
-rw-r--r--ext/mixed/js/document-util.js40
-rw-r--r--ext/mixed/js/environment.js61
2 files changed, 41 insertions, 60 deletions
diff --git a/ext/mixed/js/document-util.js b/ext/mixed/js/document-util.js
index ba39942d..0b72ff9a 100644
--- a/ext/mixed/js/document-util.js
+++ b/ext/mixed/js/document-util.js
@@ -259,6 +259,46 @@ class DocumentUtil {
return false;
}
+ static getModifierKeys(os) {
+ switch (os) {
+ case 'win':
+ return [
+ ['alt', 'Alt'],
+ ['ctrl', 'Ctrl'],
+ ['shift', 'Shift'],
+ ['meta', 'Windows']
+ ];
+ case 'mac':
+ return [
+ ['alt', 'Opt'],
+ ['ctrl', 'Ctrl'],
+ ['shift', 'Shift'],
+ ['meta', 'Cmd']
+ ];
+ case 'linux':
+ case 'openbsd':
+ case 'cros':
+ case 'android':
+ return [
+ ['alt', 'Alt'],
+ ['ctrl', 'Ctrl'],
+ ['shift', 'Shift'],
+ ['meta', 'Super']
+ ];
+ default: // 'unknown', etc
+ return [
+ ['alt', 'Alt'],
+ ['ctrl', 'Ctrl'],
+ ['shift', 'Shift'],
+ ['meta', 'Meta']
+ ];
+ }
+ }
+
+ static isMetaKeySupported(os, browser) {
+ return !(browser === 'firefox' || browser === 'firefox-mobile') || os === 'mac';
+ }
+
// Private
_setImposterStyle(style, propertyName, value) {
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};
- }
}