I have searched about difference between
keyPressed is fired whenever any key press occurs.
keyTyped is fired when a key is pressed that can be converted into a unicode character. If the shift key is down, for example, pressing "a" will tell
keyTyped that you typed a capital A, and
keyPressed will just get the "a" key, without capital or lowercase designations. You cannot call
keyPressed, because there is no key char associated with the events. Characters only come from
The basic idea is that
keyTyped is used to find characters that are typed, and
keyPressed is used for obtain raw key presses.