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.