java - How to distinguish the commonly printed keyboard keys from the rest -
i want collect keyboard input , append in java stringbuilder, using lwjgl's keyboard event, end fetching more wish, shift, capslock, escape, f1 f12, enter, punctuation etc.. these keys have key id's, appending them, printed square (unrecognized character believe).
my goal ignore these non-printable keys without having create giant array these unwanted keys. there way so?
p.s. mind wish common symbols \,.-< etc. still considered string, text editor would.
here's example of use. example used inner class , use in stead of regular actionlistener on component. example catches keycode of event (using keyevent). placed examples asked in questions, i'm sure you'll find more if needed.
you should append custom string existing string in every case of switch statement.
public class customlistener extends keyadapter { @override public void keypressed(keyevent e) { try { int keycode = e.getkeycode(); switch (keycode) { case keyevent.vk_shift: //append string existing string break; case keyevent.vk_f1: //append string existing string break; case keyevent.vk_caps_lock: //append string existing string break; case keyevent.vk_enter: //append string existing string break; } } } catch (nullpointerexception e1) { e1.printstacktrace(); } } }
Comments
Post a Comment