By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,974 Members | 1,834 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,974 IT Pros & Developers. It's quick & easy.

fire a keypress event

P: n/a
Hi, all

Is that possible to fire a "tab" key press event with javascript?

jack
Jul 23 '05 #1
Share this Question
Share on Google+
6 Replies


P: n/a
> Is that possible to fire a "tab" key press event with javascript?

Not that I know of, but what is it you want to accompish with it?
Maybe it can be done in a different way.

Jul 23 '05 #2

P: n/a
I would like to use shift+left as shift+tab and shift+right as tab.

jack
Jul 23 '05 #3

P: n/a
> I would like to use shift+left as shift+tab and shift+right as tab.

There is a object.fireEvent method, and a document.createEvent method..
you could try to manipulate those, but I tried, and I didn't succeed in
emulating a tab or shift-tab.

Jul 23 '05 #4

P: n/a
Thanks Vincent.

I ve tried to change the key code in keyDown event. It will work for
shift+left for shift+tab. For shift+right for tab, because shiftKey property
is readonly, just can't set it to false. So it works as shift+tab as well.
That's the problem!

Jack
"Vincent van Beveren" <vi*****@provident.remove.this.nl> wrote in message
news:40***********************@news.xs4all.nl...
I would like to use shift+left as shift+tab and shift+right as tab.


There is a object.fireEvent method, and a document.createEvent method..
you could try to manipulate those, but I tried, and I didn't succeed in
emulating a tab or shift-tab.

Jul 23 '05 #5

P: n/a
In the event, you can fire a new event.

newevent = document.createEventObject(oldevent)

The new event is a copy of the other event, except for that you
can modify everything.

newevent.shiftKey = false;

Now you'll need to resend it though.

oldevent.srcElement.fireEvent("on"+oldevent.type,n ewevent);

Look at the MSDN for more info
http://msdn.microsoft.com/workshop/a...ventobject.asp
http://msdn.microsoft.com/workshop/a.../fireevent.asp

Something like that.

Though I must admit, I didn't get it to work, this should work (in
theory)

Good luck,
Vincent

datactrl wrote:
Thanks Vincent.

I ve tried to change the key code in keyDown event. It will work for
shift+left for shift+tab. For shift+right for tab, because shiftKey property
is readonly, just can't set it to false. So it works as shift+tab as well.
That's the problem!


Jul 23 '05 #6

P: n/a
Thanks Vincent, I put the following code on "onkeydown".

var my1 = document.createEventObject(event);
my1.keyCode = 9;
my1.shiftKey = true;
event.srcElement.fireEvent("on"+event.type,my1);
event.keyCode = 0;
event.returnValue=false;

When I trace it, it does go to fireEvent. But it didn't work as shift+tab.

Jack
Jul 23 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.