src/editor.js
function shortcutHandler(e) {
      if (e.keyCode == self.settings.shortcut.modifier) { isMod = true } // check for modifier press(default is alt key), save to var
      if (e.keyCode == 17) { isCtrl = true } // check for ctrl/cmnd press, in order to catch ctrl/cmnd + s
      if (e.keyCode == 18) { isCtrl = false }

      // Check for alt+p and make sure were not in fullscreen - default shortcut to switch to preview
      if (isMod === true && e.keyCode == self.settings.shortcut.preview && !self.is('fullscreen')) {
        e.preventDefault();
        if (self.is('edit') && self._previewEnabled) {
          self.preview();
        }
        else if (self._editEnabled) {
          self.edit();
        }
      }
      // Check for alt+f - default shortcut to make editor fullscreen
      if (isMod === true && e.keyCode == self.settings.shortcut.fullscreen && self._fullscreenEnabled) {
        e.preventDefault();
        self._goFullscreen(fsElement);
      }

      // Set the modifier key to false once *any* key combo is completed
      // or else, on Windows, hitting the alt key will lock the isMod state to true (ticket #133)
      if (isMod === true && e.keyCode !== self.settings.shortcut.modifier) {
        isMod = false;
      }

      // When a user presses "esc", revert everything!
      if (e.keyCode == 27 && self.is('fullscreen')) {
        self._exitFullscreen(fsElement);
      }

      // Check for ctrl + s (since a lot of people do it out of habit) and make it do nothing
      if (isCtrl === true && e.keyCode == 83) {
        self.save();
        e.preventDefault();
        isCtrl = false;
      }

      // Do the same for Mac now (metaKey == cmd).
      if (e.metaKey && e.keyCode == 83) {
        self.save();
        e.preventDefault();
      }

    }
function shortcutHandler(e) {
      if (e.keyCode == self.settings.shortcut.modifier) { isMod = true } // check for modifier press(default is alt key), save to var
      if (e.keyCode == 17) { isCtrl = true } // check for ctrl/cmnd press, in order to catch ctrl/cmnd + s
      if (e.keyCode == 18) { isCtrl = false }

      // Check for alt+p and make sure were not in fullscreen - default shortcut to switch to preview
      if (isMod === true && e.keyCode == self.settings.shortcut.preview && !self.is('fullscreen')) {
        e.preventDefault();
        if (self.is('edit') && self._previewEnabled) {
          self.preview();
        }
        else if (self._editEnabled) {
          self.edit();
        }
      }
      // Check for alt+f - default shortcut to make editor fullscreen
      if (isMod === true && e.keyCode == self.settings.shortcut.fullscreen && self._fullscreenEnabled) {
        e.preventDefault();
        self._goFullscreen(fsElement);
      }

      // Set the modifier key to false once *any* key combo is completed
      // or else, on Windows, hitting the alt key will lock the isMod state to true (ticket #133)
      if (isMod === true && e.keyCode !== self.settings.shortcut.modifier) {
        isMod = false;
      }

      // When a user presses "esc", revert everything!
      if (e.keyCode == 27 && self.is('fullscreen')) {
        self._exitFullscreen(fsElement);
      }

      // Check for ctrl + s (since a lot of people do it out of habit) and make it do nothing
      if (isCtrl === true && e.keyCode == 83) {
        self.save();
        e.preventDefault();
        isCtrl = false;
      }

      // Do the same for Mac now (metaKey == cmd).
      if (e.metaKey && e.keyCode == 83) {
        self.save();
        e.preventDefault();
      }

    }
function shortcutHandler ( e ) { if ( e . keyCode == self . settings . shortcut . modifier ) { isMod = true } // check for modifier press(default is alt key), save to var if ( e . keyCode == 17 ) { isCtrl = true } // check for ctrl/cmnd press, in order to catch ctrl/cmnd + s if ( e . keyCode == 18 ) { isCtrl = false } // Check for alt+p and make sure were not in fullscreen - default shortcut to switch to preview if ( isMod === true && e . keyCode == self . settings . shortcut . preview && ! self . is ( 'fullscreen' ) ) { e . preventDefault ( ) ; if ( self . is ( 'edit' ) && self . _previewEnabled ) { self . preview ( ) ; } else if ( self . _editEnabled ) { self . edit ( ) ; } } // Check for alt+f - default shortcut to make editor fullscreen if ( isMod === true && e . keyCode == self . settings . shortcut . fullscreen && self . _fullscreenEnabled ) { e . preventDefault ( ) ; self . _goFullscreen ( fsElement ) ; } // Set the modifier key to false once *any* key combo is completed // or else, on Windows, hitting the alt key will lock the isMod state to true (ticket #133) if ( isMod === true && e . keyCode !== self . settings . shortcut . modifier ) { isMod = false ; } // When a user presses "esc", revert everything! if ( e . keyCode == 27 && self . is ( 'fullscreen' ) ) { self . _exitFullscreen ( fsElement ) ; } // Check for ctrl + s (since a lot of people do it out of habit) and make it do nothing if ( isCtrl === true && e . keyCode == 83 ) { self . save ( ) ; e . preventDefault ( ) ; isCtrl = false ; } // Do the same for Mac now (metaKey == cmd). if ( e . metaKey && e . keyCode == 83 ) { self . save ( ) ; e . preventDefault ( ) ; } }
Add keyboard shortcuts for convenience.
Add keyboard shortcuts for convenience .