-
Notifications
You must be signed in to change notification settings - Fork 1
/
feature-detection.js
36 lines (23 loc) · 856 Bytes
/
feature-detection.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
export const isMac = (function () {
if (typeof navigator === 'undefined')
return false
if (navigator.userAgentData && navigator.userAgentData.platform)
return navigator.userAgentData.platform === 'macOS'
return /Mac|iPhone|iPad/.test(navigator.platform)
}())
export const isSafari = typeof navigator !== 'undefined'
&& navigator.vendor === 'Apple Computer, Inc.'
export const isIos = typeof navigator !== 'undefined'
&& /iPhone|iPad/.test(navigator.platform)
export const touchSupported = typeof document !== 'undefined'
&& 'ontouchstart' in document.documentElement
export const isCommantrol = isMac
? event => event.metaKey // Command
: event => event.ctrlKey
export function isCommantrolOnly(event) {
if (!isCommantrol(event))
return false
return isMac
? event.keyCode === 91 // Meta
: event.keyCode === 17 // Control
}