Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

keyCode - firefox

 
Joe Shannow
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
is here anybody who knows how to rewrite this javascript function (which works in IE8) to firefox?

function enter2tab(){
if(window.event.keyCode == 13 && window.event.srcElement.id !='scrap:btnSubmit') window.event.keyCode = 9;
}

When I press enter in irefox, form is submitted......
 
Joe Shannow
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Some progress:

function enter2tab(e) {
if (e.keyCode == 13)
{
e.cancelBubble = true;
e.preventDefault();
e.returnValue = false;
e.keyCode = 9;
}
}

....onkeypress="enter2tab(event); ">

this function forbids enter to submitt form... but not change the key pressed to tab
 
Joe Shannow
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hmm, firefox seems not to be able to CHANGE key events on run.
I think, it can sniff the e.keyCode and tell what the key was pressed, but not to change it.

Am I right?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic