0

I'm working on a project in Java. In my code I've JTextArea and I'm writing keyPressedEvent of JTextArea. The argument is of type java.awt.event.KeyEvent. When I use evt.getKeyCode() it returns me an int value. I wanna know that the returned value is ASCII value of character or Unicode value?

Zohaib Aslam
  • 585
  • 1
  • 4
  • 15
  • possible duplicate of [In Java, is it possible to check if a String is only ASCII?](http://stackoverflow.com/questions/3585053/in-java-is-it-possible-to-check-if-a-string-is-only-ascii) – Kick Buttowski Jan 11 '15 at 07:15
  • Use KeyEvent.VK_KEYNAME – Czipperz Jan 11 '15 at 07:19
  • Java uses Unicode internally, it has never been limited to ASCII (fortunately so); now, a KeyEvent may, or may not, refer to a Unicode code point. – fge Jan 11 '15 at 07:27
  • I got the answer at "Java Docs" http://docs.oracle.com/javase/7/docs/api/java/awt/event/KeyEvent.html KeyEvent uses unicode encoding. Here is the line explaining from the documentation `They are generated when a Unicode character is entered, and are the preferred way to find out about character input.` – Zohaib Aslam Jan 11 '15 at 07:27
  • 1
    KeyCode use neither, it's an internal constant known as virtual key – MadProgrammer Jan 11 '15 at 08:26
  • @MadProgrammer your comment solved my problem. – Zohaib Aslam Jan 12 '15 at 13:30

0 Answers0