Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using e.keyCode || e.which; how to determine the difference between lowercase and uppercase?

I am using e.keyCode || e.which; to determine which key was pressed, but I am getting 65 for both a and A why is this happening and how can I detect the difference between the two?

like image 422
Babiker Avatar asked Dec 09 '10 17:12

Babiker


People also ask

How do you know if a string is upper and lowercase?

Traverse the string character by character from start to end. Check the ASCII value of each character for the following conditions: If the ASCII value lies in the range of [65, 90], then it is an uppercase letter. If the ASCII value lies in the range of [97, 122], then it is a lowercase letter.

How do you know if a character is uppercase?

isUpperCase(char ch) determines if the specified character is an uppercase character. A character is uppercase if its general category type, provided by Character. getType(ch), is UPPERCASE_LETTER. or it has contributory property Other_Uppercase as defined by the Unicode Standard.

Is upper case in JavaScript?

The toUpperCase() method returns the value of the string converted to uppercase. This method does not affect the value of the string itself since JavaScript strings are immutable.


1 Answers

just use e.which in jquery. They normalize this value for all browsers.

Additionally you can check for e.shiftKey.

like image 200
Josiah Ruddell Avatar answered Nov 13 '22 23:11

Josiah Ruddell