diff options
| author | sestinj <sestinj@gmail.com> | 2023-07-15 15:10:48 -0700 | 
|---|---|---|
| committer | sestinj <sestinj@gmail.com> | 2023-07-15 15:10:48 -0700 | 
| commit | 152e3ae0d5455e621bd37cf7962478e9fa03f5eb (patch) | |
| tree | 455c1fffa360aed894d8f745f810af247ddfdf6a /extension/react-app/src/util | |
| parent | abe77c56abd7aea66fa85bd1257f76dc2d435a15 (diff) | |
| parent | 48e5c8001e897eb37493357087410ee8f98217fa (diff) | |
| download | sncontinue-152e3ae0d5455e621bd37cf7962478e9fa03f5eb.tar.gz sncontinue-152e3ae0d5455e621bd37cf7962478e9fa03f5eb.tar.bz2 sncontinue-152e3ae0d5455e621bd37cf7962478e9fa03f5eb.zip | |
Merge remote origin main
Diffstat (limited to 'extension/react-app/src/util')
| -rw-r--r-- | extension/react-app/src/util/index.ts | 30 | 
1 files changed, 30 insertions, 0 deletions
| diff --git a/extension/react-app/src/util/index.ts b/extension/react-app/src/util/index.ts new file mode 100644 index 00000000..ad711321 --- /dev/null +++ b/extension/react-app/src/util/index.ts @@ -0,0 +1,30 @@ +type Platform = "mac" | "linux" | "windows" | "unknown"; + +function getPlatform(): Platform { +  const platform = window.navigator.platform.toUpperCase(); +  if (platform.indexOf("MAC") >= 0) { +    return "mac"; +  } else if (platform.indexOf("LINUX") >= 0) { +    return "linux"; +  } else if (platform.indexOf("WIN") >= 0) { +    return "windows"; +  } else { +    return "unknown"; +  } +} + +function isMetaEquivalentKeyPressed(event: { +  metaKey: boolean; +  ctrlKey: boolean; +}): boolean { +  const platform = getPlatform(); +  switch (platform) { +    case "mac": +      return event.metaKey; +    case "linux": +    case "windows": +      return event.ctrlKey; +    default: +      return event.metaKey; +  } +} | 
