Welcome to Code Forum!

Join a community that supports you and your coding journey from day one. We strive to be a friendly, supportive community that empowers everyone to be better developers. By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!
  • Guest, before posting your code please take these rules into consideration:
    • It is required to use our BBCode feature to display your code. While within the editor click < / > or >_ and place your code within the BB Code prompt. This helps others with finding a solution by making it easier to read and easier to copy.
    • You can also use markdown to share your code. When using markdown your code will be automatically converted to BBCode. For help with markdown check out the markdown guide.
    • Don't share a wall of code. All we want is the problem area, the code related to your issue.

    GIF shows where to locate </> in the thread and or post editor toolbar.
    To learn more about how to use our BBCode feature, review our "How to post your code into threads" here.

    Thank you, Code Forum.

Playing Audio Using Keystrokes: Is It Possible?

Annabelle5893

Gold Coder
I'm wondering, how would I make an app that plays audio files using the keys on the number pad? Specifically, I want to make an app that triggers "Rotary Pulse 1" by pressing 1 on the numeric keypad, all the way up to "Rotary Pulse 0" on the 0 key. A dial tone will be toggled on by pressing the spacebar, which will begin with a "receiver pickup" noise. The dial tone turns off when digits are dialed via the numeric keypad. If you press the spacebar either when the dial tone is on, or after dialing a number, a "Receiver Hang Up" noise will be triggered. With the rotary dial sounds, the dial turning to the fingerhole is triggered at key down, and the release of the dial returning to the resting position will be triggered by releasing of the number corresponding to the fingerhole (1, 2, 3, 4, 5, 6, 7, 8, 9, 0). This will be accompanied by the internal sound of the dial pulses as heard in a telephone. What is the code I would use to make this audio app using HTML?
 
Where would I place the "keydown" parameter?
Please see this reply

instead of calling document.onkeypress, just call document.onkeydown
 
Please see this reply

instead of calling document.onkeypress, just call document.onkeydown
So from what you explain, this should be put in the javascript of each reference of the keycode and audio file?
 
Please see this reply

instead of calling document.onkeypress, just call document.onkeydown
How does this look?
JavaScript:
function reload(){location.reload(true);}
var allowDial;allowDial=true;var availableNumbers=["0","611","711","811","911","*67 + 1 (847) 765-1008","1 (847) 765-1008","867-5309","1 (212) 456-1414","555-1212","555-5555","748-0900","650-0050","650-8950","970-3920","1 (714) 733-9969","*57","*69"];function numberSuggestion(){var randomNumber=Math.floor(Math.random()*(availableNumbers.length));var suggestedNumber=availableNumbers[randomNumber];document.getElementById("suggestion").innerHTML="How about dialing <strong id='suggestedTelephoneNumber'>"+suggestedNumber+"</strong>? Don't like this number? Click the button above again!";}
var dialTone;var isOffHook=false;var callIncoming=false;function receiverRaised(){if(allowDial===false){telephoneAnswered();}
else{offHook();}}
setCallTimeout();function setCallTimeout(){var delay=5000;var delayCaller=Math.floor((Math.random()*8000)+1);delay=delay+delayCaller;setTimeout(incomingCall,delay);}
function ringTelephone(){
   //code for this function here
}

function incomingCall(){
    ringTelephone();

var ringRing=new Audio('Ringing Tone/Princess%20702B%20Bell%20Ring.ogg');var hasTelephoneBeenAnswered=false;function incomingCall(){function ringTelephone(){if(!hasTelephoneBeenAnswered){ringRing.play();ringRing.currentTime=0;}}

    if(isOffHook===false){
        ringRing.play();
        allowDial=false;
        callIncoming=true;
        setInterval(ringTelephone,5500);
    }
}
function dial1(){if(allowDial){numberDial();number=number+"1";var tone1=new Audio('file:///M:/Documents/Virtual%20Phone/DTMF%20Tone%20Dials/DTMF%20Tone%20Dial%201.ogg');tone1.play();}}
function dial2(){if(allowDial){numberDial();number=number+"2";var tone2=new Audio('file:///M:/Documents/Virtual%20Phone/DTMF%20Tone%20Dials/DTMF%20Tone%20Dial%202.ogg');tone2.play();}}
function dial3(){if(allowDial){numberDial();number=number+"3";var tone3=new Audio('file:///M:/Documents/Virtual%20Phone/DTMF%20Tone%20Dials/DTMF Tone Dial 3.ogg');tone3.play();}}
function dial4(){if(allowDial){numberDial();number=number+"4";var tone4=new Audio('file:///M:/Documents/Virtual%20Phone/DTMF%20Tone%20Dials/DTMF Tone Dial 4.ogg');tone4.play();}}
function dial5(){if(allowDial){numberDial();number=number+"5";var tone5=new Audio('file:///M:/Documents/Virtual%20Phone/DTMF%20Tone%20Dials/DTMF Tone Dial 5.ogg');tone5.play();}}
function dial6(){if(allowDial){numberDial();number=number+"6";var tone6=new Audio('file:///M:/Documents/Virtual%20Phone/DTMF%20Tone%20Dials/DTMF Tone Dial 6.ogg');tone6.play();}}
function dial7(){if(allowDial){numberDial();number=number+"7";var tone7=new Audio('file:///M:/Documents/Virtual%20Phone/DTMF%20Tone%20Dials/DTMF Tone Dial 7.ogg');tone7.play();}}
function dial8(){if(allowDial){numberDial();number=number+"8";var tone8=new Audio('file:///M:/Documents/Virtual%20Phone/DTMF%20Tone%20Dials/DTMF Tone Dial 8.ogg');tone8.play();}}
function dial9(){if(allowDial){numberDial();number=number+"9";var tone9=new Audio('file:///M:/Documents/Virtual%20Phone/DTMF%20Tone%20Dials/DTMF Tone Dial 9.ogg');tone9.play();}}
function dial0(){if(allowDial){numberDial();number=number+"0";var tone0=new Audio('file:///M:/Documents/Virtual%20Phone/DTMF%20Tone%20Dials/DTMF Tone Dial 0.ogg');tone0.play();}}
function dialStar(){if(allowDial){numberDial();number=number+"*";var toneStar=new Audio('file:///M:/Documents/Virtual%20Phone/DTMF%20Tone%20Dials/DTMF Tone Dial Star.ogg');toneStar.play();}}
function dialPound(){if(allowDial){numberDial();number=number+"#";var tonePound=new Audio('file:///M:/Documents/Virtual%20Phone/DTMF%20Tone%20Dials/DTMF Tone Dial Pound.ogg');tonePound.play();}}
document.onkeydown=function(e){var key=48||key=96){dial0();}
document.onkeydown=function(e){var key=49||key=97){dial1();}
document.onkeydown=function(e){var key=50||key=98){dial2();}
document.onkeydown=function(e){var key=51||key=99){dial3();}
document.onkeydown=function(e){var key=52||key=100){dial4();}
document.onkeydown=function(e){var key=53||key=101){dial5();}
document.onkeydown=function(e){var key=54||key=102){dial6();}
document.onkeydown=function(e){var key=55||key=103){dial7();}
document.onkeydown=function(e){var key=56||key=104){dial8();}
document.onkeydown=function(e){var key=57||key=105){dial9();}
document.onkeydown=function(e){var key=106){dialStar();}
document.onkeydown=function(e){var key=109){dialPound();}
var ringingTone=new Audio('Ringing Tone/Princess%20702B%20Bell%20Ring.ogg');var timesRung=0;function dial(){allowDial=false;function ring(){ringingTone.play();timesRung++;if(timesRung>1){setTimeout(response,700);}}
ring();setTimeout(ring,4000);}
function response(){switch(number){case "0":var operatorPickup=new Audio('callResponses/OperatorAnswer.wav');operatorPickup.addEventListener("ended",function(){number=prompt("Operator, your number please? (Numbers only; enter 'police' for police and emergency)");if(number==null){number="0";}
operatorPutCallThrough();});operatorPickup.play();break;case "611":var pickup611=new Audio('callResponses/611.wav');pickup611.addEventListener("ended",function(){timeoutHowler();});pickup611.play();break;case "711":var pickup711=new Audio('callResponses/tdd-1.mp3');pickup711.play();break;case "811":var pickup611=new Audio('callResponses/811.wav');pickup811.addEventListener("ended",function(){timeoutHowler();});pickup811.play();break;case "911":var pickup911=new Audio('callResponses/911-xxx-fleet.mp3');pickup911.addEventListener("ended",function(){timeoutHowler();});pickup911.play();break;case "18477651008":var pickupMCI=new Audio('callResponses/MCI.wav');pickupMCI.play();break;case "8675309":var pickup8675309=new Audio('callResponses/discoornis-bell-f1.mp3');pickup8675309.addEventListener("ended",function(){timeoutHowler();});pickup8675309.play();break;case "12124561414":busy();break;case "5551212":busy();break;case "5555555":var pickup5555555=new Audio('callResponses/timeout-xxx-fleet.mp3');pickup5555555.addEventListener("ended",function(){timeoutHowler();});pickup5555555.play();break;case "7480900":var pickupSelf=new Audio('callResponses/partyline-xxx-fleet.mp3');pickupSelf.play();break;case "18005820655":busy();break;case "6508950":var pickupAM=new Audio('callResponses/answering-machine-1.mp3');pickupAM.play();break;case "6500050":var pickupModem=new Audio('modem.wav');pickupModem.play();break;case "9703920":var pickupFax=new Audio('fax-1.mp3');pickupFax.play();break;case "17147339969":var pickup714=new Audio('device-conference.mp3');pickup714.play();break;case "*8217147339969":var pickup714=new Audio('device-conference.mp3');pickup714.play();break;case "*6717147339969":var pickup714block=new Audio('callResponses/reject2-xxx-fleet.mp3');pickup714block.addEventListener("ended",function(){timeoutHowler();});pickup714block.play();break;case "*57":var randNum57=Math.random()>=0.5;if(randNum57){var pickupCallTrace=new Audio('callResponses/trace3-xxx-fleet.mp3');}
else{var pickupCallTrace=new Audio('callResponses/trace-xxx-fleet.mp3');}
pickupCallTrace.addEventListener("ended",function(){timeoutHowler();});pickupCallTrace.play();break;case "*69":var pickupStar69=new Audio('callResponses/return-xxx-fleet.mp3');pickupStar69.addEventListener("ended",function(){timeoutHowler();});pickupStar69.play();break;case "police":var pickupPolice=new Audio('callResponses/policePickup.wav');pickupPolice.addEventListener("ended",function(){var policeComplaint=prompt("Police Department, Sergeant Duffy Speaking.");confirm("Really? You say that "+policeComplaint);var policeHangup=new Audio('callResponses/policeHangup.wav');policeHangup.addEventListener("ended",function(){timeoutHowler();});policeHangup.play();});pickupPolice.play();break;default:var pickupDefault;if(number.length>7){pickupDefault=new Audio('callResponses/ldcircuits-bell-f1.mp3');}
{else{pickupDefault=new Audio('callResponses/completeordc-xxx-fleet.mp3');}
{pickupDefault.addEventListener("ended",function(){timeoutHowler();});pickupDefault.play();}}
{//function busy}
 
Now I get this error that says: "invalid assignment left-hand side". I'm not exactly sure what that means, but it's on line 100, column 39. Upon pressing enter on the link to that specific line, I can't tell what the "Invalid assignment" could possibly be. Here's the code from that line:
JavaScript:
document.onkeydown=function(e){var key=48||key=96){dial0();}
What this is supposed to mean is, 0 is dialed if either key 48 or key 96 is pressed. Is it truly possible to assign something to a key that has two different key codes?
 
Now I get this error that says: "invalid assignment left-hand side". I'm not exactly sure what that means, but it's on line 100, column 39. Upon pressing enter on the link to that specific line, I can't tell what the "Invalid assignment" could possibly be. Here's the code from that line:
JavaScript:
document.onkeydown=function(e){var key=48||key=96){dial0();}
What this is supposed to mean is, 0 is dialed if either key 48 or key 96 is pressed. Is it truly possible to assign something to a key that has two different key codes?
Sorry for the late response, I was not available yesterday..but if you look at your code there:
1) that is not how you assign values with the OR operator. You were close.
The correct way is
JavaScript:
var key = 48 || 96;

2) There is closing parenthesis and a closing bracket that do not belong there, can you find where those are? 😉

3) In case the issues pointed out in (2) are intended, I am going to assume that you meant to add an if-statement there
 
Sorry for the late response, I was not available yesterday..but if you look at your code there:
1) that is not how you assign values with the OR operator. You were close.
The correct way is
JavaScript:
var key = 48 || 96;

2) There is closing parenthesis and a closing bracket that do not belong there, can you find where those are? 😉

3) In case the issues pointed out in (2) are intended, I am going to assume that you meant to add an if-statement there
Now it says "Missing ( before formal parameters". Here's the code of Line 100.
JavaScript:
document.onkeydown=function{(e)var key = 48 || 96;}{dial0();}
 
Now it says "Missing ( before formal parameters". Here's the code of Line 100.
JavaScript:
document.onkeydown=function{(e)var key = 48 || 96;}{dial0();}
can you tell me why that opening bracket right after the word "function" is not correct?
can you also tell me what is your reasoning behind
JavaScript:
 {dial();}
 
I'm not sure how to answer the first question, but I wonder, should the {dial);} be more like (dial);
I'm confused!
ok, so allow me to express once more the importance of working with expanded code locally while you develop your application, and only transforming all your code to the minified version once it is ready to be uploaded into production/your hosting service.

minified version
JavaScript:
document.onkeydown=function{(e)var key = 48 || 96;}{dial0();}

expanded version
JavaScript:
document.onkeydown= function {
    (e)var key = 48 || 96;
}
{
    dial0();
}
 
ok, so allow me to express once more the importance of working with expanded code locally while you develop your application, and only transforming all your code to the minified version once it is ready to be uploaded into production/your hosting service.

minified version
JavaScript:
document.onkeydown=function{(e)var key = 48 || 96;}{dial0();}

expanded version
JavaScript:
document.onkeydown= function {
    (e)var key = 48 || 96;
}
{
    dial0();
}
now let's look at each issue one at a time
 
1) wrong function definition
What is the difference between your code, and the corrected version?

JavaScript:
// your code
document.onkeydown = function {
    (e)var key = 48 || 96;
}

//corrected
document.onkeydown = function (event) {
  var thisVar = thisValue || thatValue;
}
 
2) no function/conditional-statement definition
JavaScript:
//your code
{
    dial0();
}

//possible corrections
//function definition
function myFunction (params){
    dial0();
}

//conditional statement (if-statement) definition
if( thisVar === 48 || thisVar === 96 ) {
    dial0();
}
 
How's this?
JavaScript:
<script>
function reload(){location.reload(true);}
var allowDial;allowDial=true;var availableNumbers=["0","611","711","811","911","*67 + 1 (847) 765-1008","1 (847) 765-1008","867-5309","1 (212) 456-1414","555-1212","555-5555","748-0900","650-0050","650-8950","970-3920","1 (714) 733-9969","*57","*69"];function numberSuggestion(){var randomNumber=Math.floor(Math.random()*(availableNumbers.length));var suggestedNumber=availableNumbers[randomNumber];document.getElementById("suggestion").innerHTML="How about dialing <strong id='suggestedTelephoneNumber'>"+suggestedNumber+"</strong>? Don't like this number? Click the button above again!";}
var dialTone;var isOffHook=false;var callIncoming=false;function receiverRaised(){if(allowDial===false){telephoneAnswered();}
else{offHook();}}
setCallTimeout();function setCallTimeout(){var delay=5000;var delayCaller=Math.floor((Math.random()*8000)+1);delay=delay+delayCaller;setTimeout(incomingCall,delay);}
function ringTelephone(){
   //code for this function here
}

function incomingCall(){
    ringTelephone();

var ringRing=new Audio('Ringing Tone/Princess%20702B%20Bell%20Ring.ogg');var hasTelephoneBeenAnswered=false;function incomingCall(){function ringTelephone(){if(!hasTelephoneBeenAnswered){ringRing.play();ringRing.currentTime=0;}}

    if(isOffHook===false){
        ringRing.play();
        allowDial=false;
        callIncoming=true;
        setInterval(ringTelephone,5500);
    }
}
function dial1(){if(allowDial){numberDial();number=number+"1";var tone1=new Audio('file:///M:/Documents/Virtual%20Phone/DTMF%20Tone%20Dials/DTMF%20Tone%20Dial%201.ogg');tone1.play();}}
function dial2(){if(allowDial){numberDial();number=number+"2";var tone2=new Audio('file:///M:/Documents/Virtual%20Phone/DTMF%20Tone%20Dials/DTMF%20Tone%20Dial%202.ogg');tone2.play();}}
function dial3(){if(allowDial){numberDial();number=number+"3";var tone3=new Audio('file:///M:/Documents/Virtual%20Phone/DTMF%20Tone%20Dials/DTMF Tone Dial 3.ogg');tone3.play();}}
function dial4(){if(allowDial){numberDial();number=number+"4";var tone4=new Audio('file:///M:/Documents/Virtual%20Phone/DTMF%20Tone%20Dials/DTMF Tone Dial 4.ogg');tone4.play();}}
function dial5(){if(allowDial){numberDial();number=number+"5";var tone5=new Audio('file:///M:/Documents/Virtual%20Phone/DTMF%20Tone%20Dials/DTMF Tone Dial 5.ogg');tone5.play();}}
function dial6(){if(allowDial){numberDial();number=number+"6";var tone6=new Audio('file:///M:/Documents/Virtual%20Phone/DTMF%20Tone%20Dials/DTMF Tone Dial 6.ogg');tone6.play();}}
function dial7(){if(allowDial){numberDial();number=number+"7";var tone7=new Audio('file:///M:/Documents/Virtual%20Phone/DTMF%20Tone%20Dials/DTMF Tone Dial 7.ogg');tone7.play();}}
function dial8(){if(allowDial){numberDial();number=number+"8";var tone8=new Audio('file:///M:/Documents/Virtual%20Phone/DTMF%20Tone%20Dials/DTMF Tone Dial 8.ogg');tone8.play();}}
function dial9(){if(allowDial){numberDial();number=number+"9";var tone9=new Audio('file:///M:/Documents/Virtual%20Phone/DTMF%20Tone%20Dials/DTMF Tone Dial 9.ogg');tone9.play();}}
function dial0(){if(allowDial){numberDial();number=number+"0";var tone0=new Audio('file:///M:/Documents/Virtual%20Phone/DTMF%20Tone%20Dials/DTMF Tone Dial 0.ogg');tone0.play();}}
function dialStar(){if(allowDial){numberDial();number=number+"*";var toneStar=new Audio('file:///M:/Documents/Virtual%20Phone/DTMF%20Tone%20Dials/DTMF Tone Dial Star.ogg');toneStar.play();}}
function dialPound(){if(allowDial){numberDial();number=number+"#";var tonePound=new Audio('file:///M:/Documents/Virtual%20Phone/DTMF%20Tone%20Dials/DTMF Tone Dial Pound.ogg');tonePound.play();}}
document.onkeydown=function {
if( thisVar === 48 || thisVar === 96 ) {
    dial0();
}
document.onkeydown=function {
if( thisVar === 49 || thisVar === 97 ) {
    dial1();
}
document.onkeydown=function {
if( thisVar === 50 || thisVar === 98 ) {
    dial2();
}
document.onkeydown=function {
if( thisVar === 51 || thisVar === 99 ) {
    dial3();
}
document.onkeydown=function {
if( thisVar === 52 || thisVar === 100 ) {
    dial4();
}
document.onkeydown=function {
if( thisVar === 53 || thisVar === 101 ) {
    dial5();
}
document.onkeydown=function {
if( thisVar === 54 || thisVar === 102 ) {
    dial6();
}
document.onkeydown=function {
if( thisVar === 55 || thisVar === 103 ) {
    dial7();
}
document.onkeydown=function {
if( thisVar === 56 || thisVar === 104 ) {
    dial8();
}
document.onkeydown=function {
if( thisVar === 57 || thisVar === 105 ) {
    dial9();
}
document.onkeydown=function {
if( thisVar === 106 ) {
    dialStar();
}
document.onkeydown=function {
if( thisVar === 109 ) {
    dialPound();
}
var ringingTone=new Audio('Ringing Tone/Princess%20702B%20Bell%20Ring.ogg');var timesRung=0;function dial(){allowDial=false;function ring(){ringingTone.play();timesRung++;if(timesRung>1){setTimeout(response,700);}}
ring();setTimeout(ring,4000);}
function {response(){switch(number){case "0":var operatorPickup=new Audio('callResponses/OperatorAnswer.wav');operatorPickup.addEventListener("ended",function(){number=prompt("Operator, your number please? (Numbers only; enter 'police' for police and emergency)");if(number==null){number="0";}
operatorPutCallThrough();});operatorPickup.play();break;case "611":var pickup611=new Audio('callResponses/611.wav');pickup611.addEventListener("ended",function(){timeoutHowler();});pickup611.play();break;case "711":var pickup711=new Audio('callResponses/tdd-1.mp3');pickup711.play();break;case "811":var pickup611=new Audio('callResponses/811.wav');pickup811.addEventListener("ended",function(){timeoutHowler();});pickup811.play();break;case "911":var pickup911=new Audio('callResponses/911-xxx-fleet.mp3');pickup911.addEventListener("ended",function(){timeoutHowler();});pickup911.play();break;case "18477651008":var pickupMCI=new Audio('callResponses/MCI.wav');pickupMCI.play();break;case "8675309":var pickup8675309=new Audio('callResponses/discoornis-bell-f1.mp3');pickup8675309.addEventListener("ended",function(){timeoutHowler();});pickup8675309.play();break;case "12124561414":busy();break;case "5551212":busy();break;case "5555555":var pickup5555555=new Audio('callResponses/timeout-xxx-fleet.mp3');pickup5555555.addEventListener("ended",function(){timeoutHowler();});pickup5555555.play();break;case "7480900":var pickupSelf=new Audio('callResponses/partyline-xxx-fleet.mp3');pickupSelf.play();break;case "18005820655":busy();break;case "6508950":var pickupAM=new Audio('callResponses/answering-machine-1.mp3');pickupAM.play();break;case "6500050":var pickupModem=new Audio('modem.wav');pickupModem.play();break;case "9703920":var pickupFax=new Audio('fax-1.mp3');pickupFax.play();break;case "17147339969":var pickup714=new Audio('device-conference.mp3');pickup714.play();break;case "*8217147339969":var pickup714=new Audio('device-conference.mp3');pickup714.play();break;case "*6717147339969":var pickup714block=new Audio('callResponses/reject2-xxx-fleet.mp3');pickup714block.addEventListener("ended",function(){timeoutHowler();});pickup714block.play();break;case "*57":var randNum57=Math.random()>=0.5;if(randNum57){var pickupCallTrace=new Audio('callResponses/trace3-xxx-fleet.mp3');}
else{var pickupCallTrace=new Audio('callResponses/trace-xxx-fleet.mp3');}
pickupCallTrace.addEventListener("ended",function(){timeoutHowler();});pickupCallTrace.play();break;case "*69":var pickupStar69=new Audio('callResponses/return-xxx-fleet.mp3');pickupStar69.addEventListener("ended",function(){timeoutHowler();});pickupStar69.play();break;case "police":var pickupPolice=new Audio('callResponses/policePickup.wav');pickupPolice.addEventListener("ended",function(){var policeComplaint=prompt("Police Department, Sergeant Duffy Speaking.");confirm("Really? You say that "+policeComplaint);var policeHangup=new Audio('callResponses/policeHangup.wav');policeHangup.addEventListener("ended",function(){timeoutHowler();});policeHangup.play();});pickupPolice.play();break;default:var pickupDefault;if(number.length>7){pickupDefault=new Audio('callResponses/ldcircuits-bell-f1.mp3');}
{else{pickupDefault=new Audio('callResponses/completeordc-xxx-fleet.mp3');}
{pickupDefault.addEventListener("ended",function(){timeoutHowler();});pickupDefault.play();}}
{//function busy}
</script>
 
How's this?
JavaScript:
<script>
function reload(){location.reload(true);}
var allowDial;allowDial=true;var availableNumbers=["0","611","711","811","911","*67 + 1 (847) 765-1008","1 (847) 765-1008","867-5309","1 (212) 456-1414","555-1212","555-5555","748-0900","650-0050","650-8950","970-3920","1 (714) 733-9969","*57","*69"];function numberSuggestion(){var randomNumber=Math.floor(Math.random()*(availableNumbers.length));var suggestedNumber=availableNumbers[randomNumber];document.getElementById("suggestion").innerHTML="How about dialing <strong id='suggestedTelephoneNumber'>"+suggestedNumber+"</strong>? Don't like this number? Click the button above again!";}
var dialTone;var isOffHook=false;var callIncoming=false;function receiverRaised(){if(allowDial===false){telephoneAnswered();}
else{offHook();}}
setCallTimeout();function setCallTimeout(){var delay=5000;var delayCaller=Math.floor((Math.random()*8000)+1);delay=delay+delayCaller;setTimeout(incomingCall,delay);}
function ringTelephone(){
   //code for this function here
}

function incomingCall(){
    ringTelephone();

var ringRing=new Audio('Ringing Tone/Princess%20702B%20Bell%20Ring.ogg');var hasTelephoneBeenAnswered=false;function incomingCall(){function ringTelephone(){if(!hasTelephoneBeenAnswered){ringRing.play();ringRing.currentTime=0;}}

    if(isOffHook===false){
        ringRing.play();
        allowDial=false;
        callIncoming=true;
        setInterval(ringTelephone,5500);
    }
}
function dial1(){if(allowDial){numberDial();number=number+"1";var tone1=new Audio('file:///M:/Documents/Virtual%20Phone/DTMF%20Tone%20Dials/DTMF%20Tone%20Dial%201.ogg');tone1.play();}}
function dial2(){if(allowDial){numberDial();number=number+"2";var tone2=new Audio('file:///M:/Documents/Virtual%20Phone/DTMF%20Tone%20Dials/DTMF%20Tone%20Dial%202.ogg');tone2.play();}}
function dial3(){if(allowDial){numberDial();number=number+"3";var tone3=new Audio('file:///M:/Documents/Virtual%20Phone/DTMF%20Tone%20Dials/DTMF Tone Dial 3.ogg');tone3.play();}}
function dial4(){if(allowDial){numberDial();number=number+"4";var tone4=new Audio('file:///M:/Documents/Virtual%20Phone/DTMF%20Tone%20Dials/DTMF Tone Dial 4.ogg');tone4.play();}}
function dial5(){if(allowDial){numberDial();number=number+"5";var tone5=new Audio('file:///M:/Documents/Virtual%20Phone/DTMF%20Tone%20Dials/DTMF Tone Dial 5.ogg');tone5.play();}}
function dial6(){if(allowDial){numberDial();number=number+"6";var tone6=new Audio('file:///M:/Documents/Virtual%20Phone/DTMF%20Tone%20Dials/DTMF Tone Dial 6.ogg');tone6.play();}}
function dial7(){if(allowDial){numberDial();number=number+"7";var tone7=new Audio('file:///M:/Documents/Virtual%20Phone/DTMF%20Tone%20Dials/DTMF Tone Dial 7.ogg');tone7.play();}}
function dial8(){if(allowDial){numberDial();number=number+"8";var tone8=new Audio('file:///M:/Documents/Virtual%20Phone/DTMF%20Tone%20Dials/DTMF Tone Dial 8.ogg');tone8.play();}}
function dial9(){if(allowDial){numberDial();number=number+"9";var tone9=new Audio('file:///M:/Documents/Virtual%20Phone/DTMF%20Tone%20Dials/DTMF Tone Dial 9.ogg');tone9.play();}}
function dial0(){if(allowDial){numberDial();number=number+"0";var tone0=new Audio('file:///M:/Documents/Virtual%20Phone/DTMF%20Tone%20Dials/DTMF Tone Dial 0.ogg');tone0.play();}}
function dialStar(){if(allowDial){numberDial();number=number+"*";var toneStar=new Audio('file:///M:/Documents/Virtual%20Phone/DTMF%20Tone%20Dials/DTMF Tone Dial Star.ogg');toneStar.play();}}
function dialPound(){if(allowDial){numberDial();number=number+"#";var tonePound=new Audio('file:///M:/Documents/Virtual%20Phone/DTMF%20Tone%20Dials/DTMF Tone Dial Pound.ogg');tonePound.play();}}
document.onkeydown=function {
if( thisVar === 48 || thisVar === 96 ) {
    dial0();
}
document.onkeydown=function {
if( thisVar === 49 || thisVar === 97 ) {
    dial1();
}
document.onkeydown=function {
if( thisVar === 50 || thisVar === 98 ) {
    dial2();
}
document.onkeydown=function {
if( thisVar === 51 || thisVar === 99 ) {
    dial3();
}
document.onkeydown=function {
if( thisVar === 52 || thisVar === 100 ) {
    dial4();
}
document.onkeydown=function {
if( thisVar === 53 || thisVar === 101 ) {
    dial5();
}
document.onkeydown=function {
if( thisVar === 54 || thisVar === 102 ) {
    dial6();
}
document.onkeydown=function {
if( thisVar === 55 || thisVar === 103 ) {
    dial7();
}
document.onkeydown=function {
if( thisVar === 56 || thisVar === 104 ) {
    dial8();
}
document.onkeydown=function {
if( thisVar === 57 || thisVar === 105 ) {
    dial9();
}
document.onkeydown=function {
if( thisVar === 106 ) {
    dialStar();
}
document.onkeydown=function {
if( thisVar === 109 ) {
    dialPound();
}
var ringingTone=new Audio('Ringing Tone/Princess%20702B%20Bell%20Ring.ogg');var timesRung=0;function dial(){allowDial=false;function ring(){ringingTone.play();timesRung++;if(timesRung>1){setTimeout(response,700);}}
ring();setTimeout(ring,4000);}
function {response(){switch(number){case "0":var operatorPickup=new Audio('callResponses/OperatorAnswer.wav');operatorPickup.addEventListener("ended",function(){number=prompt("Operator, your number please? (Numbers only; enter 'police' for police and emergency)");if(number==null){number="0";}
operatorPutCallThrough();});operatorPickup.play();break;case "611":var pickup611=new Audio('callResponses/611.wav');pickup611.addEventListener("ended",function(){timeoutHowler();});pickup611.play();break;case "711":var pickup711=new Audio('callResponses/tdd-1.mp3');pickup711.play();break;case "811":var pickup611=new Audio('callResponses/811.wav');pickup811.addEventListener("ended",function(){timeoutHowler();});pickup811.play();break;case "911":var pickup911=new Audio('callResponses/911-xxx-fleet.mp3');pickup911.addEventListener("ended",function(){timeoutHowler();});pickup911.play();break;case "18477651008":var pickupMCI=new Audio('callResponses/MCI.wav');pickupMCI.play();break;case "8675309":var pickup8675309=new Audio('callResponses/discoornis-bell-f1.mp3');pickup8675309.addEventListener("ended",function(){timeoutHowler();});pickup8675309.play();break;case "12124561414":busy();break;case "5551212":busy();break;case "5555555":var pickup5555555=new Audio('callResponses/timeout-xxx-fleet.mp3');pickup5555555.addEventListener("ended",function(){timeoutHowler();});pickup5555555.play();break;case "7480900":var pickupSelf=new Audio('callResponses/partyline-xxx-fleet.mp3');pickupSelf.play();break;case "18005820655":busy();break;case "6508950":var pickupAM=new Audio('callResponses/answering-machine-1.mp3');pickupAM.play();break;case "6500050":var pickupModem=new Audio('modem.wav');pickupModem.play();break;case "9703920":var pickupFax=new Audio('fax-1.mp3');pickupFax.play();break;case "17147339969":var pickup714=new Audio('device-conference.mp3');pickup714.play();break;case "*8217147339969":var pickup714=new Audio('device-conference.mp3');pickup714.play();break;case "*6717147339969":var pickup714block=new Audio('callResponses/reject2-xxx-fleet.mp3');pickup714block.addEventListener("ended",function(){timeoutHowler();});pickup714block.play();break;case "*57":var randNum57=Math.random()>=0.5;if(randNum57){var pickupCallTrace=new Audio('callResponses/trace3-xxx-fleet.mp3');}
else{var pickupCallTrace=new Audio('callResponses/trace-xxx-fleet.mp3');}
pickupCallTrace.addEventListener("ended",function(){timeoutHowler();});pickupCallTrace.play();break;case "*69":var pickupStar69=new Audio('callResponses/return-xxx-fleet.mp3');pickupStar69.addEventListener("ended",function(){timeoutHowler();});pickupStar69.play();break;case "police":var pickupPolice=new Audio('callResponses/policePickup.wav');pickupPolice.addEventListener("ended",function(){var policeComplaint=prompt("Police Department, Sergeant Duffy Speaking.");confirm("Really? You say that "+policeComplaint);var policeHangup=new Audio('callResponses/policeHangup.wav');policeHangup.addEventListener("ended",function(){timeoutHowler();});policeHangup.play();});pickupPolice.play();break;default:var pickupDefault;if(number.length>7){pickupDefault=new Audio('callResponses/ldcircuits-bell-f1.mp3');}
{else{pickupDefault=new Audio('callResponses/completeordc-xxx-fleet.mp3');}
{pickupDefault.addEventListener("ended",function(){timeoutHowler();});pickupDefault.play();}}
{//function busy}
</script>
You don't need to copy your function for onkeydown multiple times...all you need is one:

JavaScript:
document.onkeydown = function (event) {
    //your if-statements here
}
 
You don't need to copy your function for onkeydown multiple times...all you need is one:

JavaScript:
document.onkeydown = function (event) {
    //your if-statements here
}
How about this code?
JavaScript:
<script>
function reload(){location.reload(true);}
var allowDial;allowDial=true;var availableNumbers=["0","611","711","811","911","*67 + 1 (847) 765-1008","1 (847) 765-1008","867-5309","1 (212) 456-1414","555-1212","555-5555","748-0900","650-0050","650-8950","970-3920","1 (714) 733-9969","*57","*69"];function numberSuggestion(){var randomNumber=Math.floor(Math.random()*(availableNumbers.length));var suggestedNumber=availableNumbers[randomNumber];document.getElementById("suggestion").innerHTML="How about dialing <strong id='suggestedTelephoneNumber'>"+suggestedNumber+"</strong>? Don't like this number? Click the button above again!";}
var dialTone;var isOffHook=false;var callIncoming=false;function receiverRaised(){if(allowDial===false){telephoneAnswered();}
else{offHook();}}
setCallTimeout();function setCallTimeout(){var delay=5000;var delayCaller=Math.floor((Math.random()*8000)+1);delay=delay+delayCaller;setTimeout(incomingCall,delay);}
function ringTelephone(){
   //code for this function here
}

function incomingCall(){
    ringTelephone();

var ringRing=new Audio('Ringing Tone/Princess%20702B%20Bell%20Ring.ogg');var hasTelephoneBeenAnswered=false;function incomingCall(){function ringTelephone(){if(!hasTelephoneBeenAnswered){ringRing.play();ringRing.currentTime=0;}}

    if(isOffHook===false){
        ringRing.play();
        allowDial=false;
        callIncoming=true;
        setInterval(ringTelephone,5500);
    }
}
function dial1(){if(allowDial){numberDial();number=number+"1";var tone1=new Audio('file:///M:/Documents/Virtual%20Phone/DTMF%20Tone%20Dials/DTMF%20Tone%20Dial%201.ogg');tone1.play();}}
function dial2(){if(allowDial){numberDial();number=number+"2";var tone2=new Audio('file:///M:/Documents/Virtual%20Phone/DTMF%20Tone%20Dials/DTMF%20Tone%20Dial%202.ogg');tone2.play();}}
function dial3(){if(allowDial){numberDial();number=number+"3";var tone3=new Audio('file:///M:/Documents/Virtual%20Phone/DTMF%20Tone%20Dials/DTMF Tone Dial 3.ogg');tone3.play();}}
function dial4(){if(allowDial){numberDial();number=number+"4";var tone4=new Audio('file:///M:/Documents/Virtual%20Phone/DTMF%20Tone%20Dials/DTMF Tone Dial 4.ogg');tone4.play();}}
function dial5(){if(allowDial){numberDial();number=number+"5";var tone5=new Audio('file:///M:/Documents/Virtual%20Phone/DTMF%20Tone%20Dials/DTMF Tone Dial 5.ogg');tone5.play();}}
function dial6(){if(allowDial){numberDial();number=number+"6";var tone6=new Audio('file:///M:/Documents/Virtual%20Phone/DTMF%20Tone%20Dials/DTMF Tone Dial 6.ogg');tone6.play();}}
function dial7(){if(allowDial){numberDial();number=number+"7";var tone7=new Audio('file:///M:/Documents/Virtual%20Phone/DTMF%20Tone%20Dials/DTMF Tone Dial 7.ogg');tone7.play();}}
function dial8(){if(allowDial){numberDial();number=number+"8";var tone8=new Audio('file:///M:/Documents/Virtual%20Phone/DTMF%20Tone%20Dials/DTMF Tone Dial 8.ogg');tone8.play();}}
function dial9(){if(allowDial){numberDial();number=number+"9";var tone9=new Audio('file:///M:/Documents/Virtual%20Phone/DTMF%20Tone%20Dials/DTMF Tone Dial 9.ogg');tone9.play();}}
function dial0(){if(allowDial){numberDial();number=number+"0";var tone0=new Audio('file:///M:/Documents/Virtual%20Phone/DTMF%20Tone%20Dials/DTMF Tone Dial 0.ogg');tone0.play();}}
function dialStar(){if(allowDial){numberDial();number=number+"*";var toneStar=new Audio('file:///M:/Documents/Virtual%20Phone/DTMF%20Tone%20Dials/DTMF Tone Dial Star.ogg');toneStar.play();}}
function dialPound(){if(allowDial){numberDial();number=number+"#";var tonePound=new Audio('file:///M:/Documents/Virtual%20Phone/DTMF%20Tone%20Dials/DTMF Tone Dial Pound.ogg');tonePound.play();}}
document.onkeydown=function (e.keycode) {
if( thisVar === 48 || thisVar === 96 ) {
    dial0();
}
if( thisVar === 49 || thisVar === 97 ) {
    dial1();
}
if( thisVar === 50 || thisVar === 98 ) {
    dial2();
}
if( thisVar === 51 || thisVar === 99 ) {
    dial3();
}
if( thisVar === 52 || thisVar === 100 ) {
    dial4();
}
if( thisVar === 53 || thisVar === 101 ) {
    dial5();
}
if( thisVar === 54 || thisVar === 102 ) {
    dial6();
}
if( thisVar === 55 || thisVar === 103 ) {
    dial7();
}
if( thisVar === 56 || thisVar === 104 ) {
    dial8();
}
if( thisVar === 57 || thisVar === 105 ) {
    dial9();
}
if( thisVar === 106 ) {
    dialStar();
}
if( thisVar === 109 ) {
    dialPound();
}
var ringingTone=new Audio('Ringing Tone/Princess%20702B%20Bell%20Ring.ogg');var timesRung=0;function dial(){allowDial=false;function ring(){ringingTone.play();timesRung++;if(timesRung>1){setTimeout(response,700);}}
ring();setTimeout(ring,4000);}
function {response(){switch(number){case "0":var operatorPickup=new Audio('callResponses/OperatorAnswer.wav');operatorPickup.addEventListener("ended",function(){number=prompt("Operator, your number please? (Numbers only; enter 'police' for police and emergency)");if(number==null){number="0";}
operatorPutCallThrough();});operatorPickup.play();break;case "611":var pickup611=new Audio('callResponses/611.wav');pickup611.addEventListener("ended",function(){timeoutHowler();});pickup611.play();break;case "711":var pickup711=new Audio('callResponses/tdd-1.mp3');pickup711.play();break;case "811":var pickup611=new Audio('callResponses/811.wav');pickup811.addEventListener("ended",function(){timeoutHowler();});pickup811.play();break;case "911":var pickup911=new Audio('callResponses/911-xxx-fleet.mp3');pickup911.addEventListener("ended",function(){timeoutHowler();});pickup911.play();break;case "18477651008":var pickupMCI=new Audio('callResponses/MCI.wav');pickupMCI.play();break;case "8675309":var pickup8675309=new Audio('callResponses/discoornis-bell-f1.mp3');pickup8675309.addEventListener("ended",function(){timeoutHowler();});pickup8675309.play();break;case "12124561414":busy();break;case "5551212":busy();break;case "5555555":var pickup5555555=new Audio('callResponses/timeout-xxx-fleet.mp3');pickup5555555.addEventListener("ended",function(){timeoutHowler();});pickup5555555.play();break;case "7480900":var pickupSelf=new Audio('callResponses/partyline-xxx-fleet.mp3');pickupSelf.play();break;case "18005820655":busy();break;case "6508950":var pickupAM=new Audio('callResponses/answering-machine-1.mp3');pickupAM.play();break;case "6500050":var pickupModem=new Audio('modem.wav');pickupModem.play();break;case "9703920":var pickupFax=new Audio('fax-1.mp3');pickupFax.play();break;case "17147339969":var pickup714=new Audio('device-conference.mp3');pickup714.play();break;case "*8217147339969":var pickup714=new Audio('device-conference.mp3');pickup714.play();break;case "*6717147339969":var pickup714block=new Audio('callResponses/reject2-xxx-fleet.mp3');pickup714block.addEventListener("ended",function(){timeoutHowler();});pickup714block.play();break;case "*57":var randNum57=Math.random()>=0.5;if(randNum57){var pickupCallTrace=new Audio('callResponses/trace3-xxx-fleet.mp3');}
else{var pickupCallTrace=new Audio('callResponses/trace-xxx-fleet.mp3');}
pickupCallTrace.addEventListener("ended",function(){timeoutHowler();});pickupCallTrace.play();break;case "*69":var pickupStar69=new Audio('callResponses/return-xxx-fleet.mp3');pickupStar69.addEventListener("ended",function(){timeoutHowler();});pickupStar69.play();break;case "police":var pickupPolice=new Audio('callResponses/policePickup.wav');pickupPolice.addEventListener("ended",function(){var policeComplaint=prompt("Police Department, Sergeant Duffy Speaking.");confirm("Really? You say that "+policeComplaint);var policeHangup=new Audio('callResponses/policeHangup.wav');policeHangup.addEventListener("ended",function(){timeoutHowler();});policeHangup.play();});pickupPolice.play();break;default:var pickupDefault;if(number.length>7){pickupDefault=new Audio('callResponses/ldcircuits-bell-f1.mp3');}
{else{pickupDefault=new Audio('callResponses/completeordc-xxx-fleet.mp3');}
{pickupDefault.addEventListener("ended",function(){timeoutHowler();});pickupDefault.play();}}
{//function busy}
</script>
 
How about this code?
JavaScript:
<script>
function reload(){location.reload(true);}
var allowDial;allowDial=true;var availableNumbers=["0","611","711","811","911","*67 + 1 (847) 765-1008","1 (847) 765-1008","867-5309","1 (212) 456-1414","555-1212","555-5555","748-0900","650-0050","650-8950","970-3920","1 (714) 733-9969","*57","*69"];function numberSuggestion(){var randomNumber=Math.floor(Math.random()*(availableNumbers.length));var suggestedNumber=availableNumbers[randomNumber];document.getElementById("suggestion").innerHTML="How about dialing <strong id='suggestedTelephoneNumber'>"+suggestedNumber+"</strong>? Don't like this number? Click the button above again!";}
var dialTone;var isOffHook=false;var callIncoming=false;function receiverRaised(){if(allowDial===false){telephoneAnswered();}
else{offHook();}}
setCallTimeout();function setCallTimeout(){var delay=5000;var delayCaller=Math.floor((Math.random()*8000)+1);delay=delay+delayCaller;setTimeout(incomingCall,delay);}
function ringTelephone(){
   //code for this function here
}

function incomingCall(){
    ringTelephone();

var ringRing=new Audio('Ringing Tone/Princess%20702B%20Bell%20Ring.ogg');var hasTelephoneBeenAnswered=false;function incomingCall(){function ringTelephone(){if(!hasTelephoneBeenAnswered){ringRing.play();ringRing.currentTime=0;}}

    if(isOffHook===false){
        ringRing.play();
        allowDial=false;
        callIncoming=true;
        setInterval(ringTelephone,5500);
    }
}
function dial1(){if(allowDial){numberDial();number=number+"1";var tone1=new Audio('file:///M:/Documents/Virtual%20Phone/DTMF%20Tone%20Dials/DTMF%20Tone%20Dial%201.ogg');tone1.play();}}
function dial2(){if(allowDial){numberDial();number=number+"2";var tone2=new Audio('file:///M:/Documents/Virtual%20Phone/DTMF%20Tone%20Dials/DTMF%20Tone%20Dial%202.ogg');tone2.play();}}
function dial3(){if(allowDial){numberDial();number=number+"3";var tone3=new Audio('file:///M:/Documents/Virtual%20Phone/DTMF%20Tone%20Dials/DTMF Tone Dial 3.ogg');tone3.play();}}
function dial4(){if(allowDial){numberDial();number=number+"4";var tone4=new Audio('file:///M:/Documents/Virtual%20Phone/DTMF%20Tone%20Dials/DTMF Tone Dial 4.ogg');tone4.play();}}
function dial5(){if(allowDial){numberDial();number=number+"5";var tone5=new Audio('file:///M:/Documents/Virtual%20Phone/DTMF%20Tone%20Dials/DTMF Tone Dial 5.ogg');tone5.play();}}
function dial6(){if(allowDial){numberDial();number=number+"6";var tone6=new Audio('file:///M:/Documents/Virtual%20Phone/DTMF%20Tone%20Dials/DTMF Tone Dial 6.ogg');tone6.play();}}
function dial7(){if(allowDial){numberDial();number=number+"7";var tone7=new Audio('file:///M:/Documents/Virtual%20Phone/DTMF%20Tone%20Dials/DTMF Tone Dial 7.ogg');tone7.play();}}
function dial8(){if(allowDial){numberDial();number=number+"8";var tone8=new Audio('file:///M:/Documents/Virtual%20Phone/DTMF%20Tone%20Dials/DTMF Tone Dial 8.ogg');tone8.play();}}
function dial9(){if(allowDial){numberDial();number=number+"9";var tone9=new Audio('file:///M:/Documents/Virtual%20Phone/DTMF%20Tone%20Dials/DTMF Tone Dial 9.ogg');tone9.play();}}
function dial0(){if(allowDial){numberDial();number=number+"0";var tone0=new Audio('file:///M:/Documents/Virtual%20Phone/DTMF%20Tone%20Dials/DTMF Tone Dial 0.ogg');tone0.play();}}
function dialStar(){if(allowDial){numberDial();number=number+"*";var toneStar=new Audio('file:///M:/Documents/Virtual%20Phone/DTMF%20Tone%20Dials/DTMF Tone Dial Star.ogg');toneStar.play();}}
function dialPound(){if(allowDial){numberDial();number=number+"#";var tonePound=new Audio('file:///M:/Documents/Virtual%20Phone/DTMF%20Tone%20Dials/DTMF Tone Dial Pound.ogg');tonePound.play();}}
document.onkeydown=function (e.keycode) {
if( thisVar === 48 || thisVar === 96 ) {
    dial0();
}
if( thisVar === 49 || thisVar === 97 ) {
    dial1();
}
if( thisVar === 50 || thisVar === 98 ) {
    dial2();
}
if( thisVar === 51 || thisVar === 99 ) {
    dial3();
}
if( thisVar === 52 || thisVar === 100 ) {
    dial4();
}
if( thisVar === 53 || thisVar === 101 ) {
    dial5();
}
if( thisVar === 54 || thisVar === 102 ) {
    dial6();
}
if( thisVar === 55 || thisVar === 103 ) {
    dial7();
}
if( thisVar === 56 || thisVar === 104 ) {
    dial8();
}
if( thisVar === 57 || thisVar === 105 ) {
    dial9();
}
if( thisVar === 106 ) {
    dialStar();
}
if( thisVar === 109 ) {
    dialPound();
}
var ringingTone=new Audio('Ringing Tone/Princess%20702B%20Bell%20Ring.ogg');var timesRung=0;function dial(){allowDial=false;function ring(){ringingTone.play();timesRung++;if(timesRung>1){setTimeout(response,700);}}
ring();setTimeout(ring,4000);}
function {response(){switch(number){case "0":var operatorPickup=new Audio('callResponses/OperatorAnswer.wav');operatorPickup.addEventListener("ended",function(){number=prompt("Operator, your number please? (Numbers only; enter 'police' for police and emergency)");if(number==null){number="0";}
operatorPutCallThrough();});operatorPickup.play();break;case "611":var pickup611=new Audio('callResponses/611.wav');pickup611.addEventListener("ended",function(){timeoutHowler();});pickup611.play();break;case "711":var pickup711=new Audio('callResponses/tdd-1.mp3');pickup711.play();break;case "811":var pickup611=new Audio('callResponses/811.wav');pickup811.addEventListener("ended",function(){timeoutHowler();});pickup811.play();break;case "911":var pickup911=new Audio('callResponses/911-xxx-fleet.mp3');pickup911.addEventListener("ended",function(){timeoutHowler();});pickup911.play();break;case "18477651008":var pickupMCI=new Audio('callResponses/MCI.wav');pickupMCI.play();break;case "8675309":var pickup8675309=new Audio('callResponses/discoornis-bell-f1.mp3');pickup8675309.addEventListener("ended",function(){timeoutHowler();});pickup8675309.play();break;case "12124561414":busy();break;case "5551212":busy();break;case "5555555":var pickup5555555=new Audio('callResponses/timeout-xxx-fleet.mp3');pickup5555555.addEventListener("ended",function(){timeoutHowler();});pickup5555555.play();break;case "7480900":var pickupSelf=new Audio('callResponses/partyline-xxx-fleet.mp3');pickupSelf.play();break;case "18005820655":busy();break;case "6508950":var pickupAM=new Audio('callResponses/answering-machine-1.mp3');pickupAM.play();break;case "6500050":var pickupModem=new Audio('modem.wav');pickupModem.play();break;case "9703920":var pickupFax=new Audio('fax-1.mp3');pickupFax.play();break;case "17147339969":var pickup714=new Audio('device-conference.mp3');pickup714.play();break;case "*8217147339969":var pickup714=new Audio('device-conference.mp3');pickup714.play();break;case "*6717147339969":var pickup714block=new Audio('callResponses/reject2-xxx-fleet.mp3');pickup714block.addEventListener("ended",function(){timeoutHowler();});pickup714block.play();break;case "*57":var randNum57=Math.random()>=0.5;if(randNum57){var pickupCallTrace=new Audio('callResponses/trace3-xxx-fleet.mp3');}
else{var pickupCallTrace=new Audio('callResponses/trace-xxx-fleet.mp3');}
pickupCallTrace.addEventListener("ended",function(){timeoutHowler();});pickupCallTrace.play();break;case "*69":var pickupStar69=new Audio('callResponses/return-xxx-fleet.mp3');pickupStar69.addEventListener("ended",function(){timeoutHowler();});pickupStar69.play();break;case "police":var pickupPolice=new Audio('callResponses/policePickup.wav');pickupPolice.addEventListener("ended",function(){var policeComplaint=prompt("Police Department, Sergeant Duffy Speaking.");confirm("Really? You say that "+policeComplaint);var policeHangup=new Audio('callResponses/policeHangup.wav');policeHangup.addEventListener("ended",function(){timeoutHowler();});policeHangup.play();});pickupPolice.play();break;default:var pickupDefault;if(number.length>7){pickupDefault=new Audio('callResponses/ldcircuits-bell-f1.mp3');}
{else{pickupDefault=new Audio('callResponses/completeordc-xxx-fleet.mp3');}
{pickupDefault.addEventListener("ended",function(){timeoutHowler();});pickupDefault.play();}}
{//function busy}
</script>
Looks a bit better... I am just concerned about where you ended that onkeydown function. Can you convert the rest of the code into the expanded form?
 
Back
Top Bottom