title: Custom IPython Notebook keyboard shortcut to duplicate current line in edit mode
body: <p>In the IPython Notebook environment, it is possible to define custom keyboard shortcuts using the IPython Javascript API. Using the <code>%%javascript</code> magic, one may write a javascript within IPython's interactive console as follows (example described <a href="http://nbviewer.ipython.org/github/adrn/ipython/blob/2.x/examples/Notebook/User%20Interface.ipynb#Keyboard-shortcut-customization">here</a>):</p>
  
  <pre><code>%%javascript
  
  IPython.keyboard_manager.command_shortcuts.add_shortcut('r', {
      help : 'run cell',
      help_index : 'zz',
      handler : function (event) {
          IPython.notebook.execute_cell();
          return false;
      }}
  );
  </code></pre>
  
  <p>I'd like to write a javascript that creates a shortcut during edit mode that binds Ctrl-Alt-Down to the action of 'duplicate current line'---that is, move the cursor to the start of the current line, select the line, copy the line, return, paste. Essentially, I want to emulate the keyboard shortcut of Eclipse, or Ctrl-d in Notepad++, or C-a C-SPACE C-n M-w C-y in Emacs. The javascript file will take the form of the following:</p>
  
  <pre><code>%%javascript
  
  IPython.keyboard_manager.edit_shortcuts.add_shortcut('ctrl-alt-down', {
      help : 'run cell',
      help_index : 'zz',
      handler : function (event) {
          [Code that duplicates the line];
          return false;
      }}
  );
  </code></pre>
  
  <p>though my attempts suggest 'ctrl-alt-down' is the incorrect way to represent the shortcut sequence, and I can't find any documentation for the <code>keyboard_manager</code>.</p>
  
  <p>I'd rather not go with an (e.g.,) AutoHotKey solution since I want to restrict this shortcut to the edit mode of IPython Notebook.</p>