We're a community of 1.1M IT Pros here for help, advice, solutions, professional growth and fun. Join us!
1,080,617 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Start New Discussion Reply to this Discussion

PHP Help

Hi, I am trying to make a sound play on a keypress in php. I want it to sound when the user presses the enter button. But I have been having no luck with JavaScript, among others. I would be glad if you helped. Thanks.

3
Contributors
6
Replies
22 Hours
Discussion Span
11 Months Ago
Last Updated
7
Views
Question
Answered
Djmann1013
Junior Poster
106 posts since May 2012
Reputation Points: 0
Solved Threads: 3
Skill Endorsements: 0

Hello,

Have you tried to use jQuery? It has an amazing library for key events. I haven't come across such a thing in PHP before.

phorce
Master Poster
747 posts since Jul 2011
Reputation Points: 63
Solved Threads: 94
Skill Endorsements: 16
diafol
Keep Smiling
Moderator
10,838 posts since Oct 2006
Reputation Points: 1,675
Solved Threads: 1,534
Skill Endorsements: 61

I'll try JQuery.

Djmann1013
Junior Poster
106 posts since May 2012
Reputation Points: 0
Solved Threads: 3
Skill Endorsements: 0

But what is the script?

Djmann1013
Junior Poster
106 posts since May 2012
Reputation Points: 0
Solved Threads: 3
Skill Endorsements: 0
phorce
Master Poster
747 posts since Jul 2011
Reputation Points: 63
Solved Threads: 94
Skill Endorsements: 16

Here is some code if it helps (It's JavaScript):

Enter Chat and press enter
<div><input id=input placeholder=you-chat-here /></div>
Chat Output
<div id=box></div>
<div id=pubnub pub-key=demo sub-key=demo></div>
<script src=http://cdn.pubnub.com/pubnub-3.1.min.js></script>
<script>(function(){
var box = PUBNUB.$('box'), input = PUBNUB.$('input'), channel = 'chatlllll';
PUBNUB.subscribe({
channel : channel,
callback : function(text) { box.innerHTML = (''+text).replace( /[<>]/g, '' ) + '<br>' + box.innerHTML; }
});
PUBNUB.bind( 'keyup', input, function(e) {
(e.keyCode || e.charCode) === 13 && PUBNUB.publish({
playsound('http://www.aphpsite.comuv.com/sound/chat.wav')
channel : channel, message : input.value, x : (input.value='')
});
} );
})();</script>

Hope that gives you guys an idea of what I'm trying to do.

Djmann1013
Junior Poster
106 posts since May 2012
Reputation Points: 0
Solved Threads: 3
Skill Endorsements: 0
Question Answered as of 10 Months Ago by phorce and diafol

This question has already been solved: Start a new discussion instead

Post: Markdown Syntax: Formatting Help
 
You
View similar articles that have also been tagged:
 
© 2013 DaniWeb® LLC
Page generated in 0.0738 seconds using 2.71MB