keylistener - Android KeyEvent handling - KeyCode or GetUnicodeChar? -
i've been writing android app driven hardware keyboard input. i'm in process of adding soft keyboard support, i'm not quite there yet. digress...
originally checking integer keycode value passed in onkey function against enums in keyevent class. simple enough...
but need know if user pressed combination of keys generate > symbol. therefore checked if both alt pressed , x keycode passed in...but turns out different keys on different phones generate > symbol.
now, instead, i'm checking value of getunicodechar method of keyevent against known values unicode characters.
my problem solved - there accepted way character checking? people not need alt-symbols, or people using software keyboards standard across devices? there's no built-in table of unicode character enums (that know of, anyhow), makes code little uglier too. curious!
i believe correct in way detect symbol/alternative key has been pressed @ unicode character.
often, people interested in primary keys, keycode sufficient.
you can't depend on particular ime (soft keyboard) being used. note text entered through ime accessed text widgets via inputconnection, not use keyevents hardware keyboards do.
Comments
Post a Comment