Add message about disabling hotkeys if not supported

This commit is contained in:
Robbie Antenesse 2019-05-10 15:42:31 -06:00
parent 335b3dbb3e
commit c644593994
1 changed files with 5 additions and 3 deletions

View File

@ -2,8 +2,9 @@ import { confirmEditWord, submitWordForm } from "./wordManagement";
import { showSection, getIsDetailsPanelDisplayed, hideDetailsPanel } from "./displayToggles"; import { showSection, getIsDetailsPanelDisplayed, hideDetailsPanel } from "./displayToggles";
import { renderInfoModal, renderMaximizedTextbox } from "./render"; import { renderInfoModal, renderMaximizedTextbox } from "./render";
import { showSearchModal, clearSearchText } from "./search"; import { showSearchModal, clearSearchText } from "./search";
import { saveAndCloseSettingsModal, openSettingsModal } from "./settings"; import { saveAndCloseSettingsModal, openSettingsModal, saveSettings } from "./settings";
import { saveAndCloseEditModal, openEditModal } from "./dictionaryManagement"; import { saveAndCloseEditModal, openEditModal } from "./dictionaryManagement";
import { addMessage } from "./utilities";
export function enableHotKeys() { export function enableHotKeys() {
document.addEventListener('keydown', hotKeyActions); document.addEventListener('keydown', hotKeyActions);
@ -14,10 +15,11 @@ export function disableHotKeys() {
} }
export function hotKeyActions(event) { export function hotKeyActions(event) {
console.log(event);
if (typeof event.key === 'undefined' || typeof event.ctrlKey === 'undefined' || typeof event.altKey === 'undefined') { if (typeof event.key === 'undefined' || typeof event.ctrlKey === 'undefined' || typeof event.altKey === 'undefined') {
addMessage('Hotkeys disabled');
console.warn('Browser does not have required event properties for hotkeys.'); console.warn('Browser does not have required event properties for hotkeys.');
window.settings.useHotkeys = false;
saveSettings();
disableHotKeys(); disableHotKeys();
return false; return false;
} }