Doubt related to key code VK_PASTE

Hi All

Is the value of keycode returned by VK_PASTE correspond to the case when user presses CTRL+V

i had written a line of code as

if(e.getKeyCode == e.VK_PASTE)

{

System.out.println(" PASTE ");

}

I expected it to go inside IF statement on pressing CTRL+V

but it didnt happen

any other way out to catch CTRL+V event

Thanks in advance

[412 byte] By [Arti_mda] at [2007-10-2 5:49:06]
# 1
Hope you did not put the code in keyTyped because pasting does not trigger this event.
Amarisa at 2007-7-16 1:58:35 > top of Java-index,Desktop,Core GUI APIs...
# 2
No No i have not put it in keyTypedthe code was included in kleyReleased
Arti_mda at 2007-7-16 1:58:35 > top of Java-index,Desktop,Core GUI APIs...
# 3
Sorry, i stand corrected. Key typed does get triggered when you paste.
Amarisa at 2007-7-16 1:58:35 > top of Java-index,Desktop,Core GUI APIs...
# 4
ya agreed but my code is in keyReleased does that trigger when paste operation is performed
Arti_mda at 2007-7-16 1:58:35 > top of Java-index,Desktop,Core GUI APIs...
# 5
yes, infact all 3, keypressed, keyreleased and keytyped are triggered when you try to paste.
Amarisa at 2007-7-16 1:58:35 > top of Java-index,Desktop,Core GUI APIs...
# 6

This is what I found out: Ctrl V will result in KeyChar having an int value of 22 (because V is the 22nd alphabet). Likewise, Ctrl C will result in KeyChar having an int value of 3 (because C is the 3rd alphabet). You can try other Ctrl-alphabet and you will get the corresponding int value of the alphabet sequence.

In all cases, the keycode has int value of 0.

Amarisa at 2007-7-16 1:58:35 > top of Java-index,Desktop,Core GUI APIs...
# 7
[url http://java.sun.com/docs/books/tutorial/uiswing/misc/keybinding.html]How to Use Key Bindings[/url]
camickra at 2007-7-16 1:58:35 > top of Java-index,Desktop,Core GUI APIs...
# 8
Some keyboards (esp. those made by Sun) have Cut, Copy and Paste keys, and VK_CUT, VK_COPY and VK_PASTE are only generated when those keys are pressed.
uncle_alicea at 2007-7-16 1:58:35 > top of Java-index,Desktop,Core GUI APIs...