如何检查按下的键是否可打印?

时间:2015-11-26 17:18:08

标签: java awt keyevent

如何在java中的按键事件中检查按下的键是否可打印?

1 个答案:

答案 0 :(得分:2)

检查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;
    }