473,408 Members | 1,741 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,408 software developers and data experts.

arrow keys through list of div cursor links

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="cursor:pointer; cursor:hand;" onClick="return
callAction('1')">item 1</div>
<div style="cursor:pointer; cursor:hand;" onClick="return
callAction('2')">item 2</div>
<div style="cursor:pointer; cursor:hand;" onClick="return
callAction('3')">item 3</div>
Jul 16 '08 #1
5 3542
ca********@gmail.com 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="cursor:pointer; cursor:hand;" onClick="return
callAction('1')">item 1</div>
<div style="cursor:pointer; cursor:hand;" onClick="return
callAction('2')">item 2</div>
<div style="cursor:pointer; 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
Jul 16 '08 #2
Not one of the arrow keys returns anything
try it...

<body onkeypress='alert(event.keyCode)'></body >
Jul 17 '08 #3
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>
Jul 17 '08 #4
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.
Jul 18 '08 #5
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;
Jul 31 '08 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: skipc | last post by:
Hi, I am stuck... I've got a popup window that displays a list in table format with links on the bottom to navigate the list <prev> 1 2 3 ... <next> When I demo'd to the users... they...
2
by: Richard Wakeman | last post by:
Hi - On a data entry screen with misc. input boxes, such as for Name, Telephone Number, etc., when tabing down the input screen, Access will highlight whole contents in that box. Sometimes I'd...
7
by: Seash | last post by:
Hi friends , here is the sample code private void txtbox_KeyPress(object sender, System.Windows.Forms.KeyPressEventArgs e) { if(e.KeyChar == 13) //enter { txtbox2.Focus(); }
5
by: Rob | last post by:
If I use the following code: Private Sub Form1_KeyDown(ByVal sender As Object, _ ByVal e As System.Windows.Forms.KeyEventArgs) _ Handles MyBase.KeyDown Dim myKey As Integer myKey =...
1
by: Martijn Mulder | last post by:
/* I have problems detecting the Arrow Keys on a User Control. A control derived from System.Windows.Forms.Control neglects 'bare' Arrow Keys but does react on the combination <Altor <Ctrl+ Arrow...
0
by: Martijn Mulder | last post by:
/* I override IsInputKey() to direct the Arrow Keys (Cursor Keys) to my custom System.Windows.Forms.Control. But, holding down the Shift-Key prevents the Arrow Keys from coming through. How can...
1
by: VanKha | last post by:
How to move the cursor( I'm programming with Win32 console applications in visual c++ 6.0) by letting the user type in arrow keys(and obviously, I will then have some variable column and row and use...
0
by: =?Utf-8?B?UVNJRGV2ZWxvcGVy?= | last post by:
When I have an editable combobox in a DataGridView and the user tries to correct an error they can not move the cursor from character to character with the arrow keys. The arrow keys move focus...
4
by: beary | last post by:
Hi Being tested using FF 3 on WAMP server. I have spent a number of hours trying to figure this out myself. I have a html form using table cells and had a request to enable the arrow keys on a...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.