I know how to call 1 using keyevent which should be like aaa.keyPress(KeyEvent.VK_1);
Now I need to type (.) dot? But I could not find (KeyEvent.VK_DOT) or some similar command. Please help
Thanks
The "dot" is called a period ; hence it's VK_PERIOD
.
Very old question, very basic question, but the correct answer is missing.
For regular dot use:
KeyEvent.VK_PERIOD
For numpad dot use:
KeyEvent.VK_DECIMAL
VK_PERIOD
WILL NOT get it done, by the way. Sometimes the "painfully obvious" answer doesn't quite work.
VK_PERIOD
DOES NOT pick up the numpad's dot. It gets the main period, but you're left wonder why it no worky for numpad.
In case you need to respect numpad's dot (which is a strong possibility for all conceivable uses of a dot) you'll have to go with
keyEvent.getKeyChar() == '.'
Or (if you must have your KeyCodes)
keyEvent.getKeyCode() == KeyEvent.VK_PERIOD || keyEvent.getKeyCode() == KeyEvent.VK_DECIMAL
will also work.
VK_PERIOD应该做你需要的。
I am using Java 8 with Apache Netbeans. VK_PERIOD
works fine with both decimals and dot.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.