Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ctrl+- (Ctrl+Hyphen-Minus) as ShortCut Key?

It might seem natural to use Ctrl + +, Ctrl + -, and Ctrl + 0 as shortcuts for an application's zoom in, zoom out, and restore default zoom (typically 100 %) actions. Now, in Delphi, I am able to assign Ctrl + + and Ctrl + 0 as shortcuts. The former, though, requires that the plus sign of the main part of the keyboard is used; the plus sign of the numerical keypad cannot be used.

Problem arises, however, when I want to assign Ctrl + - as a shortcut. It simply doesn't work. If I assign "Ctrl+-" in the IDE, the value stored in the ShortCut property is 16495. If we subtract ssCtrl from this, we obtain 111. A work-around, one would believe, would be to assign ShortCut := 45 + ssCtrl, or, equivalently, ShortCut := Menus.ShortCut(45, [ssCtrl]), because ord('-') = 45. But that doesn't work.

However, I have found a working solution: ShortCut := 189 + ssCtrl. I choose 189 because that is the number I receive when I depress the "-" key and listen to the KeyDown event.

So, why am I not happy with this? Well, I am afraid that the constant 189 only is valid on Swedish keyboards. I have tried to read about this, and, as usual, the MSDN documentation is rather clear, but then, who knows how Delphi handles things.

like image 821
Andreas Rejbrand Avatar asked Aug 28 '10 22:08

Andreas Rejbrand


People also ask

What does Ctrl and minus do?

This will increase the zoom level in most browsers and some programs. To zoom out again, just hit CTRL+- (that's a minus sign). To reset the zoom level to 100 percent, hit CTRL+0 (that's a zero).

What does Ctrl Shift hyphen do?

317-123-4567.” A non-breaking hyphen is created by pressing CTRL-SHIFT, Hyphen. Occasionally in text you will want to keep two words together.

What is shortcut key A to Z?

Ctrl + A → Select all content. Ctrl + Z → Undo an action. Ctrl + Y → Redo an action. Ctrl + D → Delete the selected item and move it to the Recycle Bin.


1 Answers

The key code 189 is VK_OEM_MINUS in Windows.pas, so your solution isn't just for Swedes.

like image 148
Rob Kennedy Avatar answered Sep 28 '22 04:09

Rob Kennedy