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?
 
Did you read my last reply?
I still see the same mistakes with the if statements.

Also be sure to check the console every time code isn't working as expected.

You can see what the errors shown in the console mean, and then try to fix them yourself. An error message will typically tell you what line and column the error is in, and explain what is wrong. Writing in a program like VSCode will definitely be easier because it highlights the errors while you're writing the code.
If you need help with something specific, then post it here, but I can't debug your entire code for you, especially when I don't know what exactly you're trying to achieve. Debugging is a useful skill every programmer must learn.

 
Did you read my last reply?
I still see the same mistakes with the if statements.

Also be sure to check the console every time code isn't working as expected.

You can see what the errors shown in the console mean, and then try to fix them yourself. An error message will typically tell you what line and column the error is in, and explain what is wrong. Writing in a program like VSCode will definitely be easier because it highlights the errors while you're writing the code.
If you need help with something specific, then post it here, but I can't debug your entire code for you, especially when I don't know what exactly you're trying to achieve. Debugging is a useful skill every programmer must learn.

Now I'm trying to get the keys to respond by playing audio with each key press. I have all the file names and ID's right. At least I think I do. Even the Hookswitch toggle switch doesn't seem to respond when I press the spacebar, it just sticks on the same spot.
 
Yes, it makes sense why it's not working.
I'm sure there are a lot of errors in the console. If you would just check it, you will see the errors.

You don't seem to be taking my help, as you still have not fixed the if statement and are still using the same audio variable. I honestly don't know how I can help you if you're not taking my help.

I think it's just best that you learn JavaScript.


Sorry if I sound rude, but I'm trying to help you and you seem to just ignore it and ask a new question.
 
Yes, it makes sense why it's not working.
I'm sure there are a lot of errors in the console. If you would just check it, you will see the errors.

You don't seem to be taking my help, as you still have not fixed the if statement and are still using the same audio variable. I honestly don't know how I can help you if you're not taking my help.

I think it's just best that you learn JavaScript.


Sorry if I sound rude, but I'm trying to help you and you seem to just ignore it and ask a new question.
What seems to be happening is, I'm reading all the errors carefully, but I don't understand why the console wants a "got" expression. I'm not even sure how that expression works.
 
What do you mean by the console wants a got expression. As far as I know there's no such thing as a got expression in JavaScript.
What is the exact error message shown in the console?
 
It's saying it was expecting to find an expression, but instead found a closing bracket.
Most likely you have a misplaced or missing closing curly bracket.

Check for any missing/misplaced curly brackets or other syntax errors around line 88.
 
You opened a curly bracket at line 82, column 21, but you never closed it.
Every opening quote, bracket, curly bracket & square bracket must have a closing pair.
 
Look at the end of that line. It says Virtual Phone.html:85:14
The first part (Virtual Phone.html) is saying the error was found in the file named Virtual Phone.html.
The second part (85) is the line the error is in. In this case, line 85.
The last part (14) is the column where the error is.
So this error is in line 85, column 14 in Virtual Phone.html
 
Look at the end of that line. It says Virtual Phone.html:85:14
The first part (Virtual Phone.html) is saying the error was found in the file named Virtual Phone.html.
The second part (85) is the line the error is in. In this case, line 85.
The last part (14) is the column where the error is.
So this error is in line 85, column 14 in Virtual Phone.html
Now I've got this error. 1687453819915.png
What does 09:53:58.384 stand for?
 
There's a missing closing bracket at line 67, column 39.

Most of the errors you're showing here are missing closing brackets or curly brackets. Go through your code and make sure you have properly closed all brackets and curly brackets.
 
Back
Top Bottom