0

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
7
Views
5 Years
Discussion Span
Last Post by Djmann1013
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.

0

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.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.