diff --git a/IPython/html/static/notebook/js/keyboardmanager.js b/IPython/html/static/notebook/js/keyboardmanager.js index f8c43ba..f2a1b39 100644 --- a/IPython/html/static/notebook/js/keyboardmanager.js +++ b/IPython/html/static/notebook/js/keyboardmanager.js @@ -550,8 +550,10 @@ var IPython = (function (IPython) { if (typeof(data) === 'function') { data = {help: '', help_index: '', handler: data} } + data.help_index = data.help_index || ''; + data.help = data.help || ''; if (data.help_index === '') { - data.help_index = 'zz', + data.help_index = 'zz'; } shortcut = this.normalize_shortcut(shortcut); this._shortcuts[shortcut] = data; diff --git a/examples/notebooks/User Experience.ipynb b/examples/notebooks/User Interface.ipynb similarity index 89% rename from examples/notebooks/User Experience.ipynb rename to examples/notebooks/User Interface.ipynb index 4f97714..bc0fbc4 100644 --- a/examples/notebooks/User Experience.ipynb +++ b/examples/notebooks/User Interface.ipynb @@ -12,17 +12,17 @@ "level": 1, "metadata": {}, "source": [ - "User Experience" + "User Interface" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ - "This notebook describes the user experience of the IPython Notebook. This includes both mouse and keyboard based navigation and interaction.\n", + "This notebook describes the user interface of the IPython Notebook. This includes both mouse and keyboard based navigation and interaction.\n", "\n", "
\n", - "As of IPython 2.0, the user experience has changed significantly. Because of this we highly recommend existing users to review this information after upgrading to IPython 2.0. All new users of IPython should review this information as well.\n", + "As of IPython 2.0, the user interface has changed significantly. Because of this we highly recommend existing users to review this information after upgrading to IPython 2.0. All new users of IPython should review this information as well.\n", "
" ] }, @@ -38,7 +38,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "Starting with IPython 2.0, the IPython Notebook has a modal user experience. This means that the keyboard does different things depending on which mode the Notebook is in. There are two modes: edit mode and command mode." + "Starting with IPython 2.0, the IPython Notebook has a modal user interface. This means that the keyboard does different things depending on which mode the Notebook is in. There are two modes: edit mode and command mode." ] }, { @@ -138,7 +138,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "The modal user experience of the IPython Notebook has been optimized for efficient keyboard usage. This is made possible by having two different sets of keyboard shortcuts: one set that is active in edit mode and another in command mode.\n", + "The modal user interface of the IPython Notebook has been optimized for efficient keyboard usage. This is made possible by having two different sets of keyboard shortcuts: one set that is active in edit mode and another in command mode.\n", "\n", "The most important keyboard shortcuts are `enter`, which enters edit mode, and `esc`, which enters command mode.\n", "\n", @@ -146,6 +146,13 @@ ] }, { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "The `display_edit_shortcuts()` function used here is defined in the [Utilities section](#Utilities) at the bottom of this notebook." + ] + }, + { "cell_type": "code", "collapsed": false, "input": [ @@ -259,7 +266,7 @@ "\n", "IPython.keyboard_manager.command_shortcuts.add_shortcut('r', {\n", " help : 'run cell',\n", - " help_index : 'bd',\n", + " help_index : 'zz',\n", " handler : function (event) {\n", " IPython.notebook.execute_cell();\n", " return false;\n", @@ -274,7 +281,7 @@ "\n", "IPython.keyboard_manager.command_shortcuts.add_shortcut('r', {\n", " help : 'run cell',\n", - " help_index : 'bd',\n", + " help_index : 'aa',\n", " handler : function (event) {\n", " IPython.notebook.execute_cell();\n", " return false;\n", @@ -284,11 +291,11 @@ "metadata": {}, "output_type": "display_data", "text": [ - "" + "" ] } ], - "prompt_number": 17 + "prompt_number": 6 }, { "cell_type": "markdown", @@ -296,10 +303,46 @@ "source": [ "There are a couple of points to mention about this API:\n", "\n", - "* The `help_index` field is used to sort the shortcuts in the Keyboard Shortcuts help dialog.\n", + "* The `help_index` field is used to sort the shortcuts in the Keyboard Shortcuts help dialog. It defaults to `zz`.\n", "* When a handler returns `false` it indicates that the event should stop propagating and the default action should not be performed. For further details about the `event` object or event handling, see the jQuery docs.\n", - "* If you don't need a `help` or `help_index` field, you can simply pass a function as the second argument to `add_shortcut`.\n", + "* If you don't need a `help` or `help_index` field, you can simply pass a function as the second argument to `add_shortcut`." + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "%%javascript\n", "\n", + "IPython.keyboard_manager.command_shortcuts.add_shortcut('r', function (event) {\n", + " IPython.notebook.execute_cell();\n", + " return false;\n", + "});" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "javascript": [ + "\n", + "IPython.keyboard_manager.command_shortcuts.add_shortcut('r', function (event) {\n", + " IPython.notebook.execute_cell();\n", + " return false;\n", + "});" + ], + "metadata": {}, + "output_type": "display_data", + "text": [ + "" + ] + } + ], + "prompt_number": 11 + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ "Likewise, to remove a shortcut, use `remove_shortcut`:" ] }, @@ -322,11 +365,11 @@ "metadata": {}, "output_type": "display_data", "text": [ - "" + "" ] } ], - "prompt_number": 18 + "prompt_number": 8 }, { "cell_type": "markdown", @@ -369,7 +412,7 @@ "language": "python", "metadata": {}, "outputs": [], - "prompt_number": 12 + "prompt_number": 2 } ], "metadata": {}