Hi all,

I have searched about difference between KeyPressed and KeyTyped Events but still I'm not clear about that . One thing I have found is Keypressed is triggered first than KeyTyped .

Please clarify me when these are triggered exactly . Which is appropriate to use for which purpose ?

Thanks in advance

I think that KeyPressed is triggered exactly when you press the key. Meaning that you don't have to release the key (lift you finger from the key) to be activated.
As for the KeyTyped I think that is activated you release the key, although I am not sure.

You can test this by adding a System.out.println() inside the "triggers" and when you press the key, keep it pressed and check the console what has printed. Then lifted it and check again.

If someone else knows more please correct me.

I know that the mouse events work the way I described because I used the "mousereleased" (if i remember the name correctly) as trigger for a tic-tac-toe game I made. The 'X' was displayed at the GUI when I was releasing the mouse key

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.