Bug

Submit with keyboard

Summary

open
May 22, 2007
May 22, 2007 / xl
Jun 2, 2008 / stenyak
tino
 

Attached files

No files uploaded
 
It would be great to have a fixed key combination like Ctrl-Enter or Alt-S to submit any form.

Issue report

Minor
Have not tried
 

7 Comments

pixtur:nice idea...

11 years ago

Can this be done with jquery?


xl:accesskeys?

11 years ago

afaik easiest pure html solution is accesskey="s" in every submit button. Dunno if this can be done in css.

(thanks for the link title option!!)



tino:Give me some time to check

11 years ago

i will do some research on that

xl:with jquery i could not find anything...

11 years ago

but in the popular tiddlywiki application there are usable javascript fragments (among other interesting code...):
// Default tiddler onkeypress event handler
Story.prototype.onTiddlerKeyPress = function(e)
{
	if (!e) var e = window.event;
	clearMessage();
	var consume = false;
	var title = this.getAttribute("tiddler");
	switch(e.keyCode)
		{
		case 13: // Ctrl-Enter
		case 10: // Ctrl-Enter on IE PC
		case 77: // Ctrl-Enter is "M" on some platforms
			if(e.ctrlKey)
				{
				blurElement(this);
				config.macros.toolbar.invokeCommand(this,"defaultCommand",e);
				consume = true;
				}
			break;
		case 27: // Escape
			blurElement(this);
			config.macros.toolbar.invokeCommand(this,"cancelCommand",e);
			consume = true;
			break;
		}
	e.cancelBubble = consume;
	if(consume)
		if (e.stopPropagation) e.stopPropagation();
	return(!consume);
};

tino:Yes - it's possible with jquery

11 years ago

quite simple...


$(function(){
    $('input').keydown(function(e){
        if (e.keyCode == 13) {
            $(this).parents('form').submit();
            return false;
        }
    });
});

pixtur:sounds promissing...

11 years ago (2. update 11 years ago)

I want to have that CTRL-Enter solution as well. Tino, could you give it a try?

tino:Reply to sounds promissing...

11 years ago

Sure!