Skip to main content

I'm coding a chat box. And the Characters that I enter, is not reflected as it is.

This is basically the code I'm using.

$(document).ready(function() {  $(".entry").keydown(function(event) {   console.log(String.fromCharCode(event.which));  }); }); 

And so when I type (lower-case) "a", console tab shows me "A".

special characters will not get reflected unless I create separate condition for it.

Could someone help me with a different function which does it all by itself, and returns a string as entered by the user. Or a different approach to this challenge all together. Thanks.

Actual code - chat.js

var str=''; $(document).ready(function() {  $(".entry").keydown(function(event) {   console.log(event.which);  if (event.which === 13 && event.shiftKey === false)   {   console.log(str);   event.preventDefault();  } else {   var c = event.which;   str = str.concat(String.fromCharCode(c));  }  }); }); 

So basically the every character entered would get concated to the string. and Enter key would dump the text to console.

I'm coding a chat box. And the Characters that I enter, is not reflected as it is.

This is basically the code I'm using.

$(document).ready(function(){ $(".entry").keydown(function(event) { console.log(String.fromCharCode(event.which)); }); }); 

And so when I type (lower-case) "a", console tab shows me "A".

special characters will not get reflected unless I create separate condition for it.

Could someone help me with a different function which does it all by itself, and returns a string as entered by the user. Or a different approach to this challenge all together. Thanks.

Actual code - chat.js

var str=''; $(document).ready(function(){ $(".entry").keydown(function(event) { console.log(event.which); if (event.which === 13 && event.shiftKey === false)   { console.log(str); event.preventDefault(); } else { var c = event.which; str = str.concat(String.fromCharCode(c)); } }); }); 

So basically the every character entered would get concated to the string. and Enter key would dump the text to console.

I'm coding a chat box. And the Characters that I enter, is not reflected as it is.

This is basically the code I'm using.

$(document).ready(function() {  $(".entry").keydown(function(event) {   console.log(String.fromCharCode(event.which));  }); }); 

And so when I type (lower-case) "a", console tab shows me "A".

special characters will not get reflected unless I create separate condition for it.

Could someone help me with a different function which does it all by itself, and returns a string as entered by the user. Or a different approach to this challenge all together. Thanks.

Actual code - chat.js

var str=''; $(document).ready(function() {  $(".entry").keydown(function(event) {   console.log(event.which);  if (event.which === 13 && event.shiftKey === false) {   console.log(str);   event.preventDefault();  } else {   var c = event.which;   str = str.concat(String.fromCharCode(c));  }  }); }); 

So basically the every character entered would get concated to the string. and Enter key would dump the text to console.

added 528 characters in body
Source Link
Wisam Ahmed
  • 155
  • 1
  • 2
  • 15

I'm coding a chat box. And the Characters that I enter, is not reflected as it is.

This is basically the code I'm using.

$(document).ready(function(){ $(".entry").keydown(function(event) { console.log(String.fromCharCode(event.which)); }); }); 

And so when I type (lower-case) "a", console tab shows me "A".

special characters will not get reflected unless I create separate condition for it.

Could someone help me with a different function which does it all by itself, and returns a string as entered by the user. Or a different approach to this challenge all together. Thanks.

Actual code - chat.js

var str=''; $(document).ready(function(){ $(".entry").keydown(function(event) { console.log(event.which); if (event.which === 13 && event.shiftKey === false) { console.log(str); event.preventDefault(); } else { var c = event.which; str = str.concat(String.fromCharCode(c)); } }); }); 

So basically the every character entered would get concated to the string. and Enter key would dump the text to console.

I'm coding a chat box. And the Characters that I enter, is not reflected as it is.

This is basically the code I'm using.

$(document).ready(function(){ $(".entry").keydown(function(event) { console.log(String.fromCharCode(event.which)); }); }); 

And so when I type (lower-case) "a", console tab shows me "A".

special characters will not get reflected unless I create separate condition for it.

Could someone help me with a different function which does it all by itself, and returns a string as entered by the user. Or a different approach to this challenge all together. Thanks.

I'm coding a chat box. And the Characters that I enter, is not reflected as it is.

This is basically the code I'm using.

$(document).ready(function(){ $(".entry").keydown(function(event) { console.log(String.fromCharCode(event.which)); }); }); 

And so when I type (lower-case) "a", console tab shows me "A".

special characters will not get reflected unless I create separate condition for it.

Could someone help me with a different function which does it all by itself, and returns a string as entered by the user. Or a different approach to this challenge all together. Thanks.

Actual code - chat.js

var str=''; $(document).ready(function(){ $(".entry").keydown(function(event) { console.log(event.which); if (event.which === 13 && event.shiftKey === false) { console.log(str); event.preventDefault(); } else { var c = event.which; str = str.concat(String.fromCharCode(c)); } }); }); 

So basically the every character entered would get concated to the string. and Enter key would dump the text to console.

edited tags
Link
Anand G
  • 3.2k
  • 2
  • 24
  • 30
Source Link
Wisam Ahmed
  • 155
  • 1
  • 2
  • 15
Loading