restricting a particular key stroke or key code
hi guys :)
is there a shortcut (algorithm) to restrict a certain key events
ex: assuming that e is a KeyEvent object
if (e.getKeyCode() == KeyEvent.VK_ENTER ||
e.getKeyCode() == KeyEvent.VK_SPACE ||
e.getKeyCode() == KeyEvent.VK_BACKSPACE ) {
// do something
}
or in a pseudocode style
1) if keycode is not equal to space bar or enter or shift or tab f2 or f3
3) if keycode is ONLY equal to Space bar and enter and shift and tab
2) if keycode is ONLY equal to alphabet
i can make a huge if statement to accomplish what i need. (though im not yet trying it but it will eat all my spaces on my code.
is there atleast a short way to do what i want to do in here?
thanks :)
Re: restricting a particular key stroke or key code
Not fully sure what you are asking...but it seems the first two are easily covered with the code you posted (not that long). For the last, the VK_* are sequential numbers, so just use a >= VK_A && <= VK_Z
Re: restricting a particular key stroke or key code
oh yes the answer is already there.. i forgot VK are all represented by integer... how dumb i didnt notice it
got it got it.. thanks bro:)