How to Capture Ctrl+Z and Ctrol+z

I wonder if you can help with key bindings?

In our application we want to perform the behavior of Ctrl+z and Ctrl+Z to be the same.

If the caps lock is off, Ctrl-z is processed correctly. We detect a KGpress event.

However, when the caps lock is on, we can NOT process the Ctrl+Z event. There does not seem to be a either of these 2 events (kGKeyPress or kKeyRelease:) coming through on our HandleEvent() event handler

Our TGFrame derived class we define the following:
class TGFrame : public TGWindow, public TQObject

in our TGFrame constructor/init method we make the following calls.
gVirtualX->GrabKey(fId, gVirtualX->KeysymToKeycode(kKey_Z), kKeyControlMask, kTRUE);
gVirtualX->GrabKey(fId, gVirtualX->KeysymToKeycode(kKey_z), kKeyControlMask, kTRUE);

What am I missing?

Regards to all…

Angel

Hi Agel,
Try:

gVirtualX->GrabKey(fId, gVirtualX->KeysymToKeycode(kKey_z), kAnyModifier, kTRUE);
Cheers, Bertrand.

Bertrad, how are you?

I have a follow-up issue with the solution you provided.

The use of:
gVirtualX->GrabKey(fId, gVirtualX->KeysymToKeycode(kKey_z), kAnyModifier, kTRUE);

Does cause CTRL-z or CTRL-Z with CAPS Lock on to do what I need it to do. However, the user is unable to type Z in a text box. if CAPS Lock is removed they can enter z.

I tried the following call:
gVirtualX->GrabKey(fId, gVirtualX->KeysymToKeycode(kKey_z), kKeyControlMask, kTRUE); //buddy
gVirtualX->GrabKey(fId, gVirtualX->KeysymToKeycode(kKey_Z), kKeyControlMask, kTRUE); //buddy

Doesn’t seem to work for hKey_Z when CTRL-Z is pressed and Z is upper case due to CAPS Lock on.
Shouldn’t it have worked?

Thank you,
Angel

This sounds weird… Does it works with shift Z?

Well, I’m not sure… This is a X11 specific feature, and I’ll have to try it…

Bertrand,

Sorry, it does sound really poorly worded. Here is what’s going on in clear details.

We’ve mapped a ctrl-z to do a refresh of a GUI display. Sometimes the user presses Caps Lock and performs a CTRL-Z and the refresh did not work. However, with your 12/16 suggestion below it worked for ctrl-z or CTRL-Z.

gVirtualX->GrabKey(fId, gVirtualX->KeysymToKeycode(kKey_z), kAnyModifier, kTRUE)

The problem came when the user tried to use the letter “z” in a list text box, nothing was entered. They had to use the “Z”.

This is what I tried:

gVirtualX->GrabKey(fId, gVirtualX->KeysymToKeycode(kKey_z), kAnyModifier, kTRUE); //buddy

gVirtualX->GrabKey(fId, gVirtualX->KeysymToKeycode(kKey_Z), kAnyModifier, kTRUE); //buddy

And with this combo I am UNAble to type Z or z in a text field.

With this combination:

gVirtualX->GrabKey(fId, gVirtualX->KeysymToKeycode(kKey_z), kKeyControlMask, kTRUE); //buddy

gVirtualX->GrabKey(fId, gVirtualX->KeysymToKeycode(kKey_Z), kKeyControlMask, kTRUE); //buddy

The ctrl-z works, but the CTRL-Z does not trigger my refresh function. I am also able to enter “z” or “Z” in a text box.

Hope this helps.

Angel

I’d just like to point out that Ctrl+Z has a standard functionality on many systems and remapping it may confuse some users.
https://www.gnu.org/software/bash/manual/html_node/Job-Control-Basics.html