Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > arrow keys through list of div cursor links

Reply
Thread Tools

arrow keys through list of div cursor links

 
 
cantrell78@gmail.com
Guest
Posts: n/a
 
      07-16-2008
I'm dynamically building a list of divs that a user can click and sets
off an action. I was hoping to build into it a way to use the up and
down arrow keys to navigate the list and the enter key to select the
one that is focused - any idea how I could achieve this?

it's basically this:

<div style="cursorointer; cursor:hand;" onClick="return
callAction('1')">item 1</div>
<div style="cursorointer; cursor:hand;" onClick="return
callAction('2')">item 2</div>
<div style="cursorointer; cursor:hand;" onClick="return
callAction('3')">item 3</div>
 
Reply With Quote
 
 
 
 
Thomas 'PointedEars' Lahn
Guest
Posts: n/a
 
      07-16-2008
wrote:
> I'm dynamically building a list of divs that a user can click and sets
> off an action. I was hoping to build into it a way to use the up and
> down arrow keys to navigate the list and the enter key to select the
> one that is focused - any idea how I could achieve this?


You should use a `select' element, then it becomes much easier.

> it's basically this:
>
> <div style="cursorointer; cursor:hand;" onClick="return
> callAction('1')">item 1</div>
> <div style="cursorointer; cursor:hand;" onClick="return
> callAction('2')">item 2</div>
> <div style="cursorointer; cursor:hand;" onClick="return
> callAction('3')">item 3</div>


Yuck.


PointedEars
--
var bugRiddenCrashPronePieceOfJunk = (
navigator.userAgent.indexOf('MSIE 5') != -1
&& navigator.userAgent.indexOf('Mac') != -1
) // Plone, register_function.js:16
 
Reply With Quote
 
 
 
 
Laser Lips
Guest
Posts: n/a
 
      07-17-2008
Not one of the arrow keys returns anything


try it...

<body onkeypress='alert(event.keyCode)'></body >
 
Reply With Quote
 
Thomas 'PointedEars' Lahn
Guest
Posts: n/a
 
      07-17-2008
Laser Lips wrote:
> Not one of the arrow keys returns anything
>
>
> try it...
>
> <body onkeypress='alert(event.keyCode)'></body >


To whom and to what are you referring to?


PointedEars
--
Use any version of Microsoft Frontpage to create your site.
(This won't prevent people from viewing your source, but no one
will want to steal it.)
-- from <http://www.vortex-webdesign.com/help/hidesource.htm>
 
Reply With Quote
 
Laser Lips
Guest
Posts: n/a
 
      07-18-2008
cantrel...@gmail.com wants to basically move up and down through divs
using the arrow key. Moveing through them probably means highlighting
them adn then, as he says, initiaiting an action. But you cant do
that using the arrow key because in JavaScript the arrow keys do not
give of any event.
 
Reply With Quote
 
Laser Lips
Guest
Posts: n/a
 
      07-31-2008
I stand corrected ...


function handleArrowKeys(evt) {
evt = (evt) ? evt : ((window.event) ? event : null);
if (evt) {

alert(evt.keyCode);
switch (evt.keyCode) {
case 37:

break;
case 38:

break;
case 39:

break;
case 40:

break;
}
}
}

document.onkeyup = handleArrowKeys;
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
how to tell if cursor is sqlite.Cursor or psycopg2.Cursor dmaziuk Python 3 01-25-2011 04:52 AM
Arrow Keys >> | << Mouse Cursor bicomplex@gmail.com Windows 64bit 1 07-11-2007 05:48 PM
best practice for navigating through a table with arrow keys? PJ6 Javascript 2 12-03-2005 11:26 PM
Printing arrow keys through perl madhav_a_kelkar@hotmail.com Perl Misc 1 01-08-2005 12:08 PM
list of links between <div></div> Zarkas Javascript 2 01-10-2004 12:32 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57