Skip to content

Instantly share code, notes, and snippets.

@nfabian13
Created March 10, 2015 23:29
Show Gist options
  • Save nfabian13/ffd042db78db59db2a21 to your computer and use it in GitHub Desktop.
Save nfabian13/ffd042db78db59db2a21 to your computer and use it in GitHub Desktop.
Send message to all participants on Enter key pressed
//To send messages
var txtMsg = document.querySelector("#txtMsg")
$("#txtMsg").keydown(function(event){
if(event.keyCode == 13){
session.signal({
type: "chat",
data: txtMsg.value
}, function(error){
if(error){
console.log("signal error (" + error.code + "): " + error.message);
}else{
txtMsg.value = "";
}
}
);
}
}).focus(function(){
this.value = "";
}).blur(function(){
if(this.value == ""){
this.attr("placeholder", "Hit Enter key to send your message...");
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment