[SOLVED] missing key input for tilde ~ symbol?

After some quality time looking through the KeyInput source file & JavaDocs, it looks as if there’s no support for the identifying the tilde (~) symbol. I’d appreciate it if someone could verify if this the case.



If it is missing, adding it in is probably a low priority issue, but given that everything else seems to be in there, I thought I should mention it.

There is definitely an event generated for it because I use ~ is one of my command prefixes in my in-game console.



It may not have a KeyInput constant defined… though I will note, my keyboard doesn’t actually have a ~ key. It has a ` key that I can use shift to get a ~. But I saw no back-quote/back-tick key defined either. If a new constant is not added soon, you can do some experimenting with a RawInputListener to see what key code actually comes through for those events and just define your own constant for a while.

@pspeed said:
It may not have a KeyInput constant defined... though I will note, my keyboard doesn't actually have a ~ key. It has a ` key that I can use shift to get a ~. But I saw no back-quote/back-tick key defined either.

Ah, it was my mistake then - the back-quote/back-tick key is defined as KEY_GRAVE. And as you pointed out, if I really need to, I can detect ~ by combining that with shift detection. Thank you for the prompt reply.
Ah, it was my mistake then – the back-quote/back-tick key is defined as KEY_GRAVE. And as you pointed out, if I really need to, I can detect ~ by combining that with shift detection. Thank you for the prompt reply.


Wouldn't that approach break with different keyboard layouts? With a german keyboard you get tilde by pressing Alt Gr and +/* next to the "main enter". (German keyboards are in general not as programer friendly as the english layout concerning { [ ] } ~ and so on^^)

In general, if you are looking for a specific character and not a specific key then it is probably better to use a RawInputListener. It will be notified about every key event and then you can check the key character (which will already take shifts, etc. into account).

That makes sense. I think I generated some extra confusion for myself & possibly others by being imprecise; in my immediate project, what I really wanted was “to determine if the key with the ~ symbol had been pressed.” I didn’t need to know if it was actually the ~ or the symbols per say; I was referring to it as the ~ key because that's what I've always heard it called.<br /> <br /> That being said, I agree with <a href='http://hub.jmonkeyengine.org/members/enum/' rel='nofollow'>@enum</a> that my itermediate idea to differenetiate between the ~ and is not robust; if it turns out that I do need to check for such a thing, I’ll follow @pspeed 's advice and dig into the RawInputListener.



At the risk of deviating somewhat from the original topic, would RawInputListener also allow me to detect situations in which the OS / drivers have assigned key strokes to other devices? For instance, I noticed that checking the KeyInput constant for PageUp & PageDown does not detect that I’ve assigned those keystrokes to auxiliary mouse buttons (in my case 7th & 8th). In the event that other users have mapped keystrokes, it would be nice to respect their preferences.

I think it would detect them for real typed characters (but I’m not sure).



I don’t know if you would get anything special for pgup pgdn… experimentation would be in order.



If you get a key event at all then RawInputListener would catch all of them. If you wanted to ever write some way for the user to map the keys by typing them then RawInputListener would be the way to do that also.