Why event.which doesn’t return 13 (CR) or 10 (LF) depending on the operating system?
$('#something').on('keypress', function (event) {
switch (event.which) {
case 13:
...
break;
}
});
UPDATE
I know that Carriage return is equal to 13 in ASCII code. But why Carriage return is common to all operating systems but produces different outputs in text (i.e. LF, CR, CR LF)?
Because that is the ASCII code for return…
The table:
Look at number 13:
Read this:
Making the value fixed no matter which OS is being used, makes our life a lot easier and letting us focus on the real issues we need to do.