Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Chrome Userscript - Shift+Enter New Window Blocker
// ==UserScript==
// @name Chrome Shift+Enter New Window Blocker
// @namespace
// @description Stops Chrome from opening a new window when you are entering a password and press SHIFT+ENTER. Instead submits the login form.
// @copyright Joe Totaro
// @license MIT License;
// @include *
// ==/UserScript==
function supressShiftEnter(event){
//shift enter is pressed
if(event.keyCode == 13 && event.shiftKey){
var form = event.srcElement.form;
//try to submit the form
if(typeof form.submit == 'function')
return false;
return true;
var inputs = document.getElementsByTagName('input');
for (var i = 0; i < inputs.length; i++){
if (inputs[i].type == 'password'){
inputs[i].onkeypress = supressShiftEnter;

This comment has been minimized.

Show comment Hide comment

jataro May 27, 2012

Tested on Chrome 18


jataro commented May 27, 2012

Tested on Chrome 18

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment