Activate Item on Button Press or Button Release - user-interface

I have a simple GUI that I am developing for an embedded system. The menus can be navigated with the up/down keys and an item can be activated by pressing a confirm key. Presently there are no double presses or long presses planned, but they might be implemented in future releases. Right now the keys are processed on key release. I like this configuration, but could there be a reason why I would want to process a key on button press instead? Any reason why someone has a preference over key press or key release?

I'd go for key press, because it's the result of the user's desire to make something happen, and it's happening now.
Some users may move more slowly than others, so to only act on release of the key means delaying the user's intention, which goes against the UI principle of giving instant feedback for user actions.
What's your reason for preferring key release?
Incidentally, if these are actual physical switches, don't forget to do some debouncing in software. Jack Ganssle's Guide to Debouncing goes into a lot of detail on how to do this.

Related

Win32 - How do I catch key event in background, without using global key hook or RegisterHotKey?

I made a program that takes a screenshot of a game window when a specific key is pressed. I am using RegisterHotKey(). It works well, but there is a problem: when the game window is on focus, my program can't receive that key event. To take a screenshot, I have to click the desktop to move the focus to desktop, then press that key. Only in that way can my program receive the key event and take a screenshot. (the game itself provides an in-game camera to take screenshots, but the camera can't take screenshots of UI, inventory, etc. That's why I made this program.)
It's a easy fix to use global key hook, but if I use global key hook, my program will be prone to be identified as a malware (that steals password, for example.) by anti-malware softwares, meaning that I can't share it with other players. (After all, for players that are not good at computer, it is tiring to convince Windows Defender that my program is not malware.)
Is there any idea to catch the key event, but won't make my program identified as a malware?
You can set up a global key monitor by using Raw Input. To do so you need to set the RIDEV_INPUTSINK flag in the RAWINPUTDEVICE structure passed into the RegisterRawInputDevices call.

Caps Lock does not seem to work as modifier key (Insert) with NVDA running inside a virtual machine (macOS VMware Fusion)

I'm running NVDA inside a virtual machine on my macOS using VMware Fusion. I do that since many years, and it's generally a very smooth experience, except that I need to map a keyboard key to Insert. I use Karabiner-Elements to do just that: it maps my right option key to Insert. This runs just fine, but it is quite a complex installation/configuration, and when asking clients to do the same, they are quickly overwhelmed. (Sadly, while VMware Fusion offers a feature to map certain keyboard combos to different ones, it does not allow to just change a single key's [ie. right option to insert] mapping.)
So I tried to go the route of activating the NVDA option to use caps lock as modifier key, too. But this just does not seem to work - or do I do something wrong?
Would I need to keep holding caps lock while hitting (for instance) N (to show the NVDA menus)
Or would pressing and releasing caps lock trigger some special "I am on Insert now" mode, so I could just hit another key like N? And then press and release caps lock again to deactivate the "special mode" again?
Neither option works for me. What I can say though is that the "real" caps lock functionality does not get activated anymore with the option checked, unless I hit it twice in a row quickly. So it at least seems to have some effect...
Am I doing something wrong? Any help is highly appreciated.

How to change the functionality of PrtSc (PrintScreen) key?

I wrote a little program that uses the PrtSc key as a replacement for pressing / clicking the middle mouse key.
My program uses the GetAsyncKeyState API function to scan the PrtSc.
It works fine.
The problem is that the original functionality of PrtSc continues to work also.
So, as long as PrtSc is pressed, screenshots of the desktop are being made.
After a brief moment, this leads to some hickups and delays in my screen repainting.
So I would like to turn off the 'screenshot function' of PrtSc.
I tried this method of adding a registry key to change the scan code.
disable the printscreen keyboard option from windows
But this makes the PrtSc key pretty much 'disappear' for Windows.
In the sense that GetAsyncKeyState also does not see the keypresses anymore.
Does anybody know of a way to 'detach' the screenshot functionality from PrtSc, but in such a way that pressing PrtSc still generates keycodes ...?
I have a work-around for now.
Still interested in the answer to my question though...
Work-arounds (two):
I am using the Tab key instead of the PrtSc key in my program. Not entirely happy with this, since it messes with the Tab action when entering text.
Using key remapping in AutoHotkey (that I was already using)
I remap the Tab key to Middle Mouse Button, but only for the program for which I need this:
#IfWinActive "My CAD software"
*Tab::MButton
#IfWinActive

overriding system-wide (Windows) key shortcuts in Qt app

Ctrl+Escape is a global Windows shortcut for opening main system menu. But I would like my Qt application to use this shortcut without triggering Windows main menu. I know it is probably a bad idea to override system shortcuts in general, but I would like to use this shortcut is a very limited use case.
This usecase is as follows. I have a popup window containing several rows or items. This window is opened by Ctrl+Tab and while the user holds Ctrl and keep pressing Tab, the current rows are cycled through. When the user releases Ctrl, the current row is used for some operation... But sometimes it happens that user presses Ctrl+Tab and then realizes he does not want to continue. He usually presses Escape while still holding Ctrl. And then it triggers Windows system menu and normal user gets confused, choleric user get angry... which is a bad thing. In other words I would like to be able to close the popup window when user presses Ctrl+Escape. How to do that? It is even possible?
If I write the code using this shortcut like any other short, it does not work and it always triggers Windows main menu.
As I understand it, Qt will typically not receive the key event if the underlying window system has intercepted it. For example even QtCreator cannot override system-wide shortcuts.
This question is almost a duplicate of: C++/Qt Global Hotkeys
While that question is asking specifically to capture shortcuts in a hidden/background application, I think the basic concept is the same -- capture shortcuts before the window system processes them.
From that answer, UGlobalHotkey seems pretty good, and the How to use System-Wide Hotkeys in your Qt application blog post could be useful for your limited-use case (but read the comments on that blog post about fixing the example).
Also found:
https://github.com/mitei/qglobalshortcut
https://github.com/Skycoder42/QHotkey (looks like a more detailed version of above)

Replace special character with keyboard shortcut live on input

Is there any way to replace a special character with a keyboard shortcut live?
For instance: Writing $ would actually press ctrl+n or arrow key left
Every help is much appreciated!
This is primarily speculation with a little experience and research mixed in.
This sort of thing is easy enough if you are checking in an application that currently has focus, but creating a universal keypress hook? Not so much.
I built a C#/C++ program in grad school that intercepted keystrokes intended for another application, but I was only able to do it by waiting for the desired application window to open, auto-opening my own pop-up window to receive the input, and then passing keystrokes back to the original window.
I'm not saying it can't be done, period, but my background knowledge (though slightly dated) and a little cursory research isn't turning up anything in the basic scripting world that would satisfy what you appear to be after.
The only way I know how to do it (which is likely wrong) would be to have hooks in every open application, and when a textbox on the application gained focus give focus to your own text-receiving app. Analyze the keypresses, and then pass the desired text/keypresses on to the original app/textbox. This would require prior knowledge of the "windows" (i.e. all objects) in all possible apps on the machine you're working on, so you would know when a textbox received focus.
If I recall, it might be possible to tell when keys are being pressed (if you have hooks in all apps) and re-direct from there, but you might lose the first keystroke, even then.
Again, this is primarily speculative.

Resources