How to check a pressed key is printable or not?
Asked Answered
G

1

5

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

Grebe answered 26/11, 2015 at 17:18 Comment(0)
D
7

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;
    }
Definiens answered 26/11, 2015 at 17:21 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.