// Dynamically update keybindings or hotkeys function getPlatform() { if (/Mac/.test(navigator.platform)) { return "osx" } else if (/Win/.test(navigator.platform)) { return "win" } else if (/Linux/.test(navigator.platform)) { return "linux" } else { return "other" } } const platform = getPlatform() function addOSClass(osClass) { $('.keybinding').addClass(osClass) } function updateKeyBindings() { $('.keybinding').each(function() { var osx = $(this).data("osx") var linux = $(this).data("linux") var win = $(this).data("win") if (platform === "other") { if (win != linux) { var keybind = '' + osx + ' for macOS, ' + linux + ' for Linux, and ' + win + ' for Windows'; } else { var keybind = '' + linux + ' for Linux and Windows and ' + osx + ' for macOS'; } } else { var keybind = '' + $(this).data(platform) + '' } $(this).html(keybind) }) } addOSClass(platform) updateKeyBindings()