diff --git a/client/modules/IDE/components/KeyboardShortcutModal.js b/client/modules/IDE/components/KeyboardShortcutModal.js
index 3fc62e3c..b0c05553 100644
--- a/client/modules/IDE/components/KeyboardShortcutModal.js
+++ b/client/modules/IDE/components/KeyboardShortcutModal.js
@@ -2,35 +2,47 @@ import React, { PropTypes } from 'react';
import InlineSVG from 'react-inlinesvg';
const exitUrl = require('../../../images/exit.svg');
-function KeyboardShortcutModal(props) {
- return (
-
-
- Keyboard Shortcuts
-
-
-
- -
- Shift + Tab
- Tidy
-
- -
- Command + [
- Indent Code Right
-
- -
- Command + ]
- Indent Code Left
-
- -
- Command + /
- Comment Line
-
-
-
- );
+class KeyboardShortcutModal extends React.Component {
+ componentDidMount() {
+ this.isMac = navigator.userAgent.toLowerCase().indexOf('mac') !== -1;
+ }
+
+ render() {
+ return (
+
+
+ Keyboard Shortcuts
+
+
+
+ -
+ Shift + Tab
+ Tidy
+
+ -
+
+ {this.isMac ? 'Command + S' : 'Control + S'}
+
+ Save
+
+ -
+ Command + [
+ Indent Code Right
+
+ -
+ Command + ]
+ Indent Code Left
+
+ -
+ Command + /
+ Comment Line
+
+
+
+ );
+ }
}
KeyboardShortcutModal.propTypes = {
diff --git a/client/modules/IDE/pages/IDEView.js b/client/modules/IDE/pages/IDEView.js
index f7bd2599..d4b54f42 100644
--- a/client/modules/IDE/pages/IDEView.js
+++ b/client/modules/IDE/pages/IDEView.js
@@ -32,6 +32,7 @@ class IDEView extends React.Component {
super(props);
this._handleConsolePaneOnDragFinished = this._handleConsolePaneOnDragFinished.bind(this);
this._handleSidebarPaneOnDragFinished = this._handleSidebarPaneOnDragFinished.bind(this);
+ this.handleGlobalKeydown = this.handleGlobalKeydown.bind(this);
}
componentDidMount() {
@@ -51,6 +52,9 @@ class IDEView extends React.Component {
this.consoleSize = this.props.ide.consoleIsExpanded ? 180 : 29;
this.sidebarSize = this.props.ide.sidebarIsExpanded ? 200 : 20;
this.forceUpdate();
+
+ this.isMac = navigator.userAgent.toLowerCase().indexOf('mac') !== -1;
+ document.addEventListener('keydown', this.handleGlobalKeydown, false);
}
componentWillUpdate(nextProps) {
@@ -113,6 +117,15 @@ class IDEView extends React.Component {
});
}
+ handleGlobalKeydown(e) {
+ if (e.key === 's' && ((e.metaKey && this.isMac) || (e.ctrlKey && !this.isMac))) {
+ console.log('about to save project');
+ e.preventDefault();
+ e.stopPropagation();
+ this.props.saveProject();
+ }
+ }
+
render() {
return (