tags:

views:

340

answers:

1

Hello, guys

I am developing a website for nintendo wii which uses "opera" any ways what i want is that while surfing any website on wii we use "wii control".. So, the control have up/down/right/left keys on it I want those keys to behave like TAB because when you press up/down/right/left keys it scrolls the page..

Note!!! With the TAB i doesnot mean to TAB in the inputfields or text areas... I want to use the tab as we use on our PC's the tab button while we are not using our mouse

I was wondering if i can get a javascript to say something like strat TAB instead of scroll..

document.onkeypress = function(e) { if (e.keyCode == 175 || e.keyCode == 176 || e.keyCode == 178 || e.keyCode == 177) alert("pressing keys"); return true; else if (e.keyCode == 170 || e.keyCode == 174) { return false; } };

Thanks!!

+1  A: 

I can't reccomend what you're proposing from a human interface perspective, because it means changing the standard and expected behavior of the controls to something else entirely. This is extremely confusing and frustrating from the user's perspective, especially if you don't give them reasonable enough warning to expect it.

But, giving you the benefit of the doubt, what you'll want to do is:

create a new Keyboard Event: https://developer.mozilla.org/en/DOM/document.createEvent

initialize the event (with the appropriate information to fake a tab key event): https://developer.mozilla.org/en/DOM/event.initKeyEvent

and then dispatch the event: https://developer.mozilla.org/en/DOM/element.dispatchEvent

then put that code into the event handlers for your up/down/left/right keys, and return false from their handlers to suppress the default behavior.

Breton
Thanks for the reply.. can you please help me with this because i am just a bignner in javascript maybe some sample code...the links you gave are also very useful but bit higher than my level i am trying to understand those as well..