Javascript: Simple Question

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
User avatar
tecktalkcm0391
DevNet Resident
Posts: 1030
Joined: Fri May 26, 2006 9:25 am
Location: Florida

Javascript: Simple Question

Post by tecktalkcm0391 »

I have a code that is this:

Code: Select all

<body onkeyup="keyBoard(event.keyCode)">
And I want to be able to pick up the shift then wait for another key as long as its is held down.

So that in the JS code:

Code: Select all

function keyBoard(key)
{
    if ((key < 106) && (key > 95)) newkey(key - 96);
    if ((key < 58) && (key > 47)) newkey(key - 48);
    if ((key == 8) || (key == 46) || (key == 67)) clearDisplay();
    if (key == 13) calc();        // "newkey"
    if ((key == 110) || (key == 188) || (key == 190)) newkey(".");
    if ((key == 107) || (key == 187)) newkey("+"); //Add
    if ((key == 109) || (key == 189)) newkey("-"); //Subtract
    if ((key == 106) || (key == 191)) newkey("*"); //Multiply
    if (key == 111) newkey("/");   // "Divide" 
}
It would also multiply if Shift and 8 are both held down. Do you get what I am aiming for ? How would I do this?

Thanks!
User avatar
Weirdan
Moderator
Posts: 5978
Joined: Mon Nov 03, 2003 6:13 pm
Location: Odessa, Ukraine

Post by Weirdan »

User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Post by pickle »

A more descriptive subject would probably get you more answers ;)
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

well just look at that.. we've got a thread about this already. viewtopic.php?t=37059
User avatar
tecktalkcm0391
DevNet Resident
Posts: 1030
Joined: Fri May 26, 2006 9:25 am
Location: Florida

Post by tecktalkcm0391 »

I don't get that, really I am getting better at PHP, yes I know I have to look more though, but I have no clue when it comes to Javascript. I am going to get a book on it soon. Is there any manuals out there? But, yeah so what are you telling me to look at on that page? Cause it looks like your printing something. I dunno. Thanks.

P.S. I am not thinking right cause I am tried. :cry:
Post Reply