Javascript: Simple Question
Posted: Tue Jun 13, 2006 12:52 pm
I have a code that is this:
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:
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!
Code: Select all
<body onkeyup="keyBoard(event.keyCode)">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"
}Thanks!