Better browser OS detection.

Apparently Firefox on Linux changed the value of navigator.appVersion,
causing our OS detection (used to determine how to interpret different
modifier keys) to fail.

Use navigator.platform instead, which should be more stable.

http://stackoverflow.com/a/19883965/33213
This commit is contained in:
Jesper Dam 2014-03-12 11:11:52 +01:00
parent c3f6052435
commit 230784066c
1 changed files with 3 additions and 3 deletions

View File

@ -18,13 +18,13 @@ var kbdUtil = (function() {
}; };
function isMac() { function isMac() {
return navigator && !!(/macintosh/i).exec(navigator.appVersion); return navigator && !!(/mac/i).exec(navigator.platform);
} }
function isWindows() { function isWindows() {
return navigator && !!(/windows/i).exec(navigator.appVersion); return navigator && !!(/win/i).exec(navigator.platform);
} }
function isLinux() { function isLinux() {
return navigator && !!(/linux/i).exec(navigator.appVersion); return navigator && !!(/linux/i).exec(navigator.platform);
} }
// Return true if a modifier which is not the specified char modifier (and is not shift) is down // Return true if a modifier which is not the specified char modifier (and is not shift) is down