         input = cell_start_template.clone()
         if not @readonly
             input.addClass('sagews-input-live')
-            input.click () =>
+            input.click (e) =>
                 f = () =>
-                    @insert_new_cell(mark.find().from.line)
+                    line = mark.find().from.line
+                    @insert_new_cell(line)
+                    if e.shiftKey
+                        cm.replaceRange("%html\n#{CLICK_TO_EDIT}", {line:line+1,ch:0})
+                        @action
+                            execute : true
+                            advance : false
+                    if (e.altKey or e.metaKey)
+                        cm.replaceRange("%md\n#{CLICK_TO_EDIT}", {line:line+1,ch:0})
+                        @action
+                            execute : true
+                            advance : false
+
                 if IS_MOBILE
                     # It is way too easy to accidentally click on the insert new cell line on mobile.
                     bootbox.confirm "Create new cell?", (result) =>

            j = input.indexOf(")")
            if j < i and j != -1
                i = j
            html_input = to_html(input.slice(i+1).trim())
            top_input = input.slice(0,i+1)
            div.addClass("sagews-output-html")
            div.html(html_input)
            last_html = html_input
            ignore_changes = false


        #        cm   : cm
        #    return false

        output.find(".sagews-output-messages").click (e) =>
            t = $(e.target)
            if t.attr('href')?
                return
            @edit_cell
                line : mark.find().from.line - 1
                cm   : cm
