3

How can I check whether a pressed key is printable or not in a key press event in java?

Parvez M Robin
  • 154
  • 1
  • 3
  • 16

1 Answers1

4

Check this topic.

   public boolean isPrintableChar( char c ) {
        Character.UnicodeBlock block = Character.UnicodeBlock.of( c );
        return (!Character.isISOControl(c)) &&
                c != KeyEvent.CHAR_UNDEFINED &&
                block != null &&
                block != Character.UnicodeBlock.SPECIALS;
    }
Community
  • 1
  • 1
henorek
  • 472
  • 5
  • 19