// ==UserScript== // @name Disable Enter key on comments on Stack Exchange // @namespace http://stackapps.com/a/4910/10590 // @version 1.1 // @description Disable Enter key on comments on Stack Exchange // @homepage http://stackapps.com/q/2061 // @icon http://i.stack.imgur.com/6xzO1.png // @match *://*.askubuntu.com/questions* // @match *://*.mathoverflow.net/questions* // @match *://*.serverfault.com/questions* // @match *://*.stackapps.com/questions* // @match *://*.stackexchange.com/questions* // @match *://*.stackoverflow.com/questions* // @match *://*.superuser.com/questions* // ==/UserScript== function inject() { for ( var i = 0; i < arguments.length; ++i ) { if ( typeof(arguments[i]) == 'function' ) { var script = document.createElement('script'); script.type = 'text/javascript'; script.textContent = '(' + arguments[i].toString() + ')(jQuery)'; document.body.appendChild(script); } } } inject(function ($) { setTimeout( function() { // Run only on individual posts if( ( StackExchange.options.routeName.indexOf('Questions/Show') === -1 ) ) return; $(document).delegate(".comments-link, .comment-edit", "click", function(e) { var events = $(this).closest("td").find("textarea[name=comment]").data("events"); var makeShift = { handler: function(e) { if( e.keyCode === 13 && e.shiftKey ) e.shiftKey = false; else e.shiftKey = true; } }; try { events.keyup.splice(0, 0, makeShift); events.keypress.splice(0, 0, makeShift); } catch (evt) { console.error('Disable Enter key on comments on Stack Exchange failed to load'); } }); }, 500 ); });