Register | Login | |||||
Main
| Memberlist
| Active users
| Calendar
| Chat
| Online users Ranks | FAQ | ACS | Stats | Color Chart | Search | Photo album |
| |
0 users currently in Programming. |
User | Post |
HyperHacker Posts: 283/5072 |
It could just not be passing the Caps Lock key to the listener... add something to print the value of every key pressed, then hit Caps Lock a few times. If nothing gets printed, then you need to find another way to see when it's pressed. |
Euclid Posts: 13/83 |
Maybe it's your keyboard, try to find out the value for vk_caps_lock (i think it defaults to 0x20 for most cases) and the actual caps lock value on your comp, you might have to do some hardcoding... |
neotransotaku Posts: 176/1860 |
ack...i wasn't clear which default I was in.
The problem is the code thinks the caps lock key is not pressed, even when I am pressing the damn key. So...any ideas of how to get this code to recognize when caps lock is pressed. I also have a keyTyped function in the same class and it recognizes my keystrokes (so that rules out the fact that I have not added my listener). MODE_ASCII and MODE_JPN are static final ints and typeMode is initialized to MODE_ASCII |
Squash Monster Posts: 72/296 |
If the mode variables are ints, like Euclid guessed, then this code should work fine. If they're Strings or anything else you can't accurately use == with, then there's going to be a problem.
Or there could be a problem elsewhere in the program. Putting something like this in your default statement might bring something to light: System.out.println(typeMode + " : " + (typeMode == MODE_ASCII) + " : " + (typeMode == MODE_JPN)); |
Euclid Posts: 12/83 |
It looks right... assuming you did set a default value for typeMode (ascii or jpn) in some constructor before running that code.
The 2 mode variables seems to be man-made (static final ints?), i have no idea what type they are or if they're comparable, why don't you try an if statement instead and see if that works properly, and also try outputing the type of the variable before throwing an exception, that might help knowing why it has jumped to the default. |
neotransotaku Posts: 170/1860 |
it doesn't do what I intended
public void keyPressed(KeyEvent e) this code always lands me in default when I press Caps Lock... side note--if anyone knows how to disable br's inside pre with CSS, PM me with code, thanks. |