Skip to content

Commit

Permalink
Update keyboard-shortcuts.js
Browse files Browse the repository at this point in the history
  • Loading branch information
janfaracik committed May 13, 2022
1 parent 7ad4b6f commit c828d87
Showing 1 changed file with 1 addition and 24 deletions.
25 changes: 1 addition & 24 deletions war/src/main/js/keyboard-shortcuts.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,33 +40,10 @@ window.addEventListener("load", () => {
})

/**
* Translates a given keyboard shortcut, e.g. CMD+K, into an OS friendly version, e.g. CTRL+K
* Translates a given keyboard shortcut, e.g. CMD+K, into an OS neutral version, e.g. CTRL+K
* @param {string} keyboardShortcut The shortcut for translation
*/
function translateKeyboardShortcutForOS(keyboardShortcut) {
const isMac = navigator.platform.toUpperCase().indexOf("MAC") >= 0
return keyboardShortcut.replace("CMD", isMac ? "CMD" : "CTRL")
}

/**
* Translates a given keyboard shortcut, e.g. CMD+K, into a UI friendly version, e.g. ⌘+K
* @param {string} keyboardShortcut The shortcut for translation
*/
function translateKeyboardShortcutForUI(keyboardShortcut) {
const isMac = navigator.platform.toUpperCase().indexOf("MAC") >= 0
return keyboardShortcut.replace("CMD", isMac ? "⌘" : "CTRL")
}

/**
* Generates a UI representation of the given keyboard shortcut
* @param {string} keyboardShortcut The shortcut for generation
*/
export function generateKeyboardShortcutUI(keyboardShortcut) {
return translateKeyboardShortcutForUI(keyboardShortcut)
.split("+")
.map(shortcut => `<span class="shortcut">${shortcut}</span>`)
.join(ADD_SVG)
}


export default { generateKeyboardShortcutUI }

0 comments on commit c828d87

Please sign in to comment.