Ability to use the Win key to assign a specific IDE function lazarus / 11-Options ---------------------------------------------------------------------- flowCRANE · 2024-10-05 14:20 I had been working on ThinkPad laptops for a very long time, and they had a great keyboard. One of the advantages was that the up arrow key had keys with the codes VK_BROWSER_BACK and VK_BROWSER_FORWARD on either side (see the attachment). I had assigned functions to these keys that allowed me to move around the code editor tabs and jump between code editor windows (alone keys to switch between tabs in a given editor window, with the Ctrl key to switch between editor windows). This made working very convenient. I recently switched to a stationary PC and am currently working on a full-size keyboard that does not have these two keys. So I lost the ability to conveniently move between tabs and windows. For now, I have set other shortcuts for these functions (Ctrl+Tab and Shift+Ctrl+Tab to change tabs and Ctrl+` to change the editor window), but they are not convenient for me. Up until now I had my shortcuts set up so that I could either use my right hand to use these functions (e.g. BrowserNext to change tabs), or both (e.g. Ctrl+BrowserNext to change windows). Now I have to use only my left hand (e.g. Ctrl+Tab), which is a real pain for me because I have to fight muscle memory. Ideally, I could use the arrow keys combined with one of the special keys on the left side of the keyboard. The available keys are: Ctrl, Shift, Alt, and Win. I already use the first three keys for many code editor functions, so I no longer have any sensible shortcuts that would be unassigned — the Win key remains. If it were possible to use the Win key for IDE function shortcuts, I would use it — Win+Left/Right to move between tabs in the active code editor window and, for example, Ctrl+Win+Left/Right to move between code editor windows. That would be very convenient for me. Well, it would be, because the IDE does not allow the use of the Win key in IDE function shortcuts. Why? Why can't you use this key? ---------------------------------------------------------------------- Martin_fr · 2024-10-05 15:02 I know the feeling... Could us a few extra keys myself. Ignoring issue with cross platform.... Have you tried? In your own app? To react to those keys and suppress it from going to Windows? IIRC it can be suppressed (in most cases) if another key is pressed with it (while it is hold down). But if you press and depress it, without pressing another key (maybe changed your mind) then the start up menu pops up. It may not bother you, but it's not a user experience for everyone. Considering that the "Alt + Ctrl" keycodes already cause trouble, because they can't be distinguished from AltGr and that is needed to type various common keys on non English keyboards...  The Win key is going to call for even more trouble. ---------------------------------------------------------------------- marcov · 2024-10-05 15:17 IIRC those keys are reserved for system level usage on Windows, and not passed onto applications. ---------------------------------------------------------------------- 440bx · 2024-10-05 15:51 Take what follows with a grain of salt because I've never tried using the Winkey in my code. It _seems_ that it should be possible for user code to use the Winkey.  I say that because some MS Office apps make use of it.  For instance, in Onenote win-shift-s takes a screenshot (per Wikipedia.) It should not take much work to write a little test program to see if an app/window gets a WM_CHAR (or some other message) upon the winkey being pressed/depressed. Of course, using the winkey is a bit problematic because MS seems to have reserved that key for itself.  Therefore any use you make of it could easily conflict with ways it's already used or will be used in the future (by MS.) HTH. ---------------------------------------------------------------------- 440bx · 2024-10-05 16:04 Just tried it... for the winkey an app gets a WM_KEYDOWN followed by a WM_KEYUP.  Windows reacts to the WM_KEYUP.  That's when it chooses to show the start menu.  One possible useful characteristic is that if the user presses shift, alt, or ctrl _before_ pressing the winkey then Windows does not do anything.  IOW, if you required the other keys to be pressed first then you could assign some functions to combinations that include the winkey. The other possibility would be to "eat" the winkey in all cases thereby preventing windows from seeing/using it.  IOW, usurping the winkey for your program. HTH. ---------------------------------------------------------------------- Martin_fr · 2024-10-05 16:08 Yes you get the keydown/up. You can even set the "key" to zero, and in some (but not all cases) that works. On the other hand, Windows itself adds more and more shortcuts to that key. So conflicts are more and more likely. ---------------------------------------------------------------------- 440bx · 2024-10-05 16:17 Quote from: Martin_fr on October 05, 2024, 06:08:37 pmOn the other hand, Windows itself adds more and more shortcuts to that key. So conflicts are more and more likely. Yes, that's the real problem.  I cannot think of a useful/reasonable way of using the winkey that is not, at least potentially, undesirably invasive. ---------------------------------------------------------------------- Thaddy · 2024-10-05 16:36 The constants are: VK_LWIN and VK_RWIN and they are available to programmers. I am not sure these two are defined in the current Windows unit (maybe use jwaWindows instead?). I have used them elsewhere, but not in Pascal, probably C++. If they are defined correctly, there should not be any difference between these two and ctrl, alt and family. If using them is a good idea is another story, as mentioned. ---------------------------------------------------------------------- flowCRANE · 2024-10-05 16:49 Quote from: Martin_fr on October 05, 2024, 05:02:10 pmBut if you press and depress it, without pressing another key (maybe changed your mind) then the start up menu pops up. It may not bother you, but it's not a user experience for everyone. Even now, exactly the same kind of "problem" exists with the left Alt key — pressing and releasing it focuses the first item on the main menu. Does anyone complain that this is the default behavior of the system? Of course not. The real bananas will be when the user tries to set the Alt+Tab shortcut (which is currently allowed). The IDE will allow you to set such a shortcut without a problem, but it will never work properly. And the same with the Ctrl+Alt+Del shortcut. But this is just a fun fact, not a problem at all. Quote from: 440bx on October 05, 2024, 06:17:14 pmI cannot think of a useful/reasonable way of using the winkey that is not, at least potentially, undesirably invasive. I have a lot of ideas for its use, including the ones I wrote about earlier. Especially since if you execute a shortcut with the Win key (Win+something) and it is not a shortcut understood by the system (e.g. Win+L to switch users), it simply ignores it and does not open the Start menu. And as I wrote earlier, if someone wants to use a given shortcut, but it may conflict with system functions, they will do so knowing the consequences. I know that many shortcuts with the Win key are already reserved by the system, so I would use those that will not conflict with it. Currently, I have no freedom in this matter. ---------------------------------------------------------------------- 440bx · 2024-10-05 16:56 Quote from: furious programming on October 05, 2024, 06:49:02 pmI know that many shortcuts with the Win key are already reserved by the system, so I would use those that will not conflict with it. Currently, I have no freedom in this matter. The problems will occur when MS decides to use some combination(s) you decided to use too.  That is not a recipe for a desirable situation. ---------------------------------------------------------------------- flowCRANE · 2024-10-05 17:01 Quote from: 440bx on October 05, 2024, 06:56:43 pmThe problems will occur when MS decides to use some combination(s) you decided to use too. I love being treated like a retarded child, incapable of solving absolutely any problem. And I especially love it when someone knows better than me what is good for me and tries to forbid me from doing anything that might cause a problem. Even if Microsoft adds one of the system shortcuts that I would use, for God's sake, there is nothing stopping me from changing this shortcut in the IDE settings. However, as long as a given shortcut is free and the system does not use it for anything, I would like to be able to use it to improve my working conditions with the IDE. ---------------------------------------------------------------------- 440bx · 2024-10-05 17:11 Quote from: furious programming on October 05, 2024, 07:01:40 pmI love being treated like a retarded child, incapable of solving absolutely any problem. I especially love it when someone knows better than me what is good for me and tries to forbid me from doing something that might cause a problem.I got a good laugh out of that.  Quote from: furious programming on October 05, 2024, 07:01:40 pmEven if Microsoft adds one of the system shortcuts that I would use to the set of shortcuts, for God's sake, there is nothing stopping me from changing this shortcut in the IDE settings. That statement implies the program is strictly for your personal use because while you may not mind having to get accustomed to new shortcuts, users of your program may not feel the same way.  If the program is strictly for your personal use, that's a detail you could have mentioned when it was pointed out that your choices had the potential to conflict with those - eventually - made by MS. Anyway... yes, you can use the winkey however you like,  Be my guest. ---------------------------------------------------------------------- flowCRANE · 2024-10-05 17:31 I just remind not to be a hypocrite on this topic. Already now, Lazarus not only allows you to set shortcuts that are reserved by the system and will never work as intended by the user (e.g. Alt+Tab or Ctrl+Alt+Del), but it also does not inform the user about potential problems while setting these shortcuts. So I don't see any reason to prohibit the use of the Win key, since the user can already set reserved shortcuts that will not meet expectations. What's more, you can easily assign individual letter and number keys to specific IDE functions, and thus be unable to write code. Does anyone do such things? Of course not. So if Lazarus can correctly recognize the Win key and respond to shortcuts composed with this key (and it seems like it can, since other applications can do it), it would be worth adding such an option. ---------------------------------------------------------------------- Thaddy · 2024-10-05 17:46 Quote from: furious programming on October 05, 2024, 07:31:12 pmSo if Lazarus can correctly recognize the Win key and respond to shortcuts composed with this key (and it seems like it can, since other applications can do it) That doesn't require anything, just the constants. Still, if it is sane is another story. Lazarus apps will listen to VK_LWIN and VK_RWIN. I already explained that. ---------------------------------------------------------------------- 440bx · 2024-10-05 17:57 Quote from: furious programming on October 05, 2024, 07:31:12 pmAlready now, Lazarus not only allows you to set shortcuts that are reserved by the system and will never work as intended by the user (e.g. Alt+Tab or Ctrl+Alt+Del), but it also does not inform the user about potential problems while setting these shortcuts. You're going to use that as a rationale to justify using the winkey in your app ?... that doesn't sound very wise but, as I said before, use the winkey however you like.  Be my guest.  Go for it. ---------------------------------------------------------------------- flowCRANE · 2024-10-05 18:33 Quote from: 440bx on October 05, 2024, 07:57:55 pmQuote from: furious programming on October 05, 2024, 07:31:12 pmAlready now, Lazarus not only allows you to set shortcuts that are reserved by the system and will never work as intended by the user (e.g. Alt+Tab or Ctrl+Alt+Del), but it also does not inform the user about potential problems while setting these shortcuts. You're going to use that as a rationale to justify using the winkey in your app ? Lazarus is not my app. Regardless of whether or not support for the Win key for IDE shortcuts is added, the user already has the ability to break the IDE in many ways. That's why I'm pointing out that avoiding Win key support so that the user doesn't experience problems doesn't sound very wise. ---------------------------------------------------------------------- Thaddy · 2024-10-05 18:51 It is just only a matter of the constants being declared. ---------------------------------------------------------------------- flowCRANE · 2024-10-05 19:31 So do it! Do it now! In case a decision is made not to add official support for the Win key, I will ask you for help — we will try to modify my Lazarus installation so that I could use this key and assign it to some IDE functions. The Lazarus code base is huge and I'm not a contributor, so any help would be greatly appreciated. ---------------------------------------------------------------------- Thaddy · 2024-10-06 09:06 Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i const  VK_LWIN = $5B;  VK_RWIN = $5C;You can do it yourself. BTW they are declared in windows. Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i uses  Windows, Classes, SysUtils, Forms, Controls, Graphics, Dialogs, StdCtrls, ActnList; type   { TForm1 }   TForm1 = class(TForm)    Action1: TAction;    ActionList1: TActionList;  private    procedure WMKeyDown(var Msg: TWMKeyDown); message WM_KEYDOWN;  public   end; var  Form1: TForm1; implementation {$R *.lfm} { TForm1 } procedure TForm1.WMKeyDown(var Msg: TWMKeyDown);begin  case Msg.CharCode of    VK_LWIN: ShowMessage('Left Windows Key Pressed');  VK_RWIN: ShowMessage('Right Windows Key Pressed');  end;  inherited;end;end. ---------------------------------------------------------------------- Thaddy · 2024-10-06 13:07 Console example that prevents the win key being passed to the OS after all:Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i program GlobalHookExample;{$mode objfpc}{$H+}uses  jwaWindows; var  hhkLowLevelKybd: HHOOK; function LowLevelKeyboardProc(nCode: Integer; wParam: WPARAM; lParam: LPARAM): LRESULT; stdcall;var  p: PKBDLLHOOKSTRUCT;begin  if (nCode = HC_ACTION) then  begin    p := PKBDLLHOOKSTRUCT(lParam);    if (wParam = WM_KEYDOWN) and ((p^.vkCode = Ord('K')) and        ((GetAsyncKeyState(VK_LWIN) and $8000) <> 0))then    begin      writeln('Windows + K key combination pressed!');      result := 1;// prevent windows from using the win+k itself      exit;    end;  end;  Result := CallNextHookEx(hhkLowLevelKybd, nCode, wParam, lParam);end; procedure SetHook;begin  hhkLowLevelKybd := SetWindowsHookEx(WH_KEYBOARD_LL, @LowLevelKeyboardProc, HInstance, 0);  if hhkLowLevelKybd = 0 then    writeln('Failed to set hook!');end; procedure Unhook;begin  if not UnhookWindowsHookEx(hhkLowLevelKybd) then   writeln('Failed to unhook!');end; begin  SetHook;  MessageBox(0, 'Press OK to unhook and exit.'#13#10#13#10'Don''t kill me, leave open'#13#10#13#10'Just close me when you are finished', 'Global Hook Example', MB_OK);  Unhook;end.Do not close the messagebox until you want to stop the program. ---------------------------------------------------------------------- Thaddy · 2024-10-06 14:49 And a GUI version. Needs a form and a memo. Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i unit Unit1; {$mode objfpc}{$H+} interface uses  jwaWindows,Classes, SysUtils, Forms, Controls, Graphics, Dialogs, StdCtrls; type   { TForm1 }   TForm1 = class(TForm)    Memo1: TMemo;    procedure FormCreate(Sender: TObject);  private   public   end; var  Form1: TForm1;  hhkLowLevelKybd: HHOOK;  implementation{$R *.lfm}function LowLevelKeyboardProc(nCode: Integer; wParam: WPARAM; lParam: LPARAM): LRESULT; stdcall;var  p: PKBDLLHOOKSTRUCT;begin  if (nCode = HC_ACTION) then  begin    p := PKBDLLHOOKSTRUCT(lParam);    if (wParam = WM_KEYDOWN) and ((p^.vkCode = Ord('K')) and        ((GetAsyncKeyState(VK_LWIN) and $8000) <> 0)) and        ((GetAsyncKeyState(VK_SHIFT) and $8000) <> 0)    then    begin      form1.memo1.lines.add('Windows + shift + K key combination pressed!');      result := 1;      exit;    end;  end;  Result := CallNextHookEx(hhkLowLevelKybd, nCode, wParam, lParam);end; procedure SetHook;begin  hhkLowLevelKybd := SetWindowsHookEx(WH_KEYBOARD_LL, @LowLevelKeyboardProc, HInstance, 0);  if hhkLowLevelKybd = 0 then    form1.memo1.lines.add('Failed to set hook!');end; procedure Unhook;begin  if not UnhookWindowsHookEx(hhkLowLevelKybd) then   form1.Memo1.lines.add('Failed to unhook!');end; { TForm1 } procedure TForm1.FormCreate(Sender: TObject);begin  Caption := 'Capture the Windows key';  memo1.clear;  memo1.lines.add('Installed a global hook for Windows key + shift + K');end; initialization  sethook;finalization  unhook;end.Note that both the last programs prevent Windows to use the particular key combination while your app is running. I noticed that the win+shift + works best, since the OS does not seem to use that, so you can integrate it with that provision. ---------------------------------------------------------------------- n7800 · 2024-10-07 03:08 I also think that it is worth implementing. Since the user assigns the combinations themselves, they are responsible for it. As already mentioned, conflicts can also arise with "regular" modifiers. Compatibility are important only for default shortcuts. Of course, the IDE should warn the user about possible limitations, but not prohibit their use. By the way, it would be more cross- platform to call this key [Meta] instead of [Win]. The good news is that, AFAICS in the code, the IDE handles all modifier keys equally. This means that to implement "support" for the [Meta] key, you just need to add a checkbox for it! Even more surprising is that they already work! There is no checkbox for it, but you can click the "Grab key" button and simply press the key combination. The window will close if it catches a valid key combination (not occupied by the OS). You will not see [Meta] among the checkboxes, but when you click "OK", you will see the entered combination in the list opposite the command. After saving the options, you can make sure that it works. The fact that the flag is not visible when entering a combination with [Meta] can be called a bug. Users simply won't see it and won't understand why the key combination (without [Meta]) doesn't work, because it wasn't in the window when saving. That's why I still made patch to make its use more "legal" and to clearly warn the user about possible problems. I also fixed a couple of small bugs. Details are in the merge request, let's see what the developers say. Personally, I've only tested on Windows so far. ---------------------------------------------------------------------- flowCRANE · 2024-10-07 13:49 Quote from: n7800 on October 07, 2024, 05:08:09 amEven more surprising is that they already work! There is no checkbox for it, but you can click the "Grab key" button and simply press the key combination. The window will close if it catches a valid key combination (not occupied by the OS). You will not see [Meta] among the checkboxes, but when you click "OK", you will see the entered combination in the list opposite the command. After saving the options, you can make sure that it works. Wait, an additional checkbox should always be visible, on every platform, so that you can select a combination with e.g. the Win key, without having to use the Grab key option. You should also remember that there is also a Find key combination option and it should also support the ability to search for combinations with the Win key. So in short, if you are going to add this extra key, then all the options related to keys and shortcuts should respect it and fully support it (setting, finding, displaying, etc.). Please think through all cases so that the UI/UX is neat and complete. Quote from: n7800 on October 07, 2024, 05:08:09 amDetails are in the merge request, let's see what the developers say. I've checked the changes and in my opinion, the proposed solution is over-engineered (that's my impression). The fourth checkbox should always be visible and should be named according to the platform (e.g. Win on Windows, because Meta is not a valid name for a key on the keyboard and users will most likely not know which key it is). Secondly, this checkbox should be handled in the same way as the other three — it should be possible to check/uncheck it with the mouse, and the Grab Key option should automatically check/uncheck it based on the captured shortcut (without any confirmations). ---------------------------------------------------------------------- n7800 · 2024-10-08 20:52 Quote from: furious programming on October 07, 2024, 03:49:04 pmshould be named according to the platform (e.g. Win on Windows, because Meta is not a valid name for a key on the keyboard and users will most likely not know which key it is) Sounds reasonable. I'll probably make a separate MR, since there are common functions for this, but this window uses its own function. I'll see if I can remove the duplicate code. Quote from: furious programming on October 07, 2024, 03:49:04 pmYou should also remember that there is also a Find key combination option and it should also support the ability to search for combinations with the Win key. So in short, if you are going to add this extra key, then all the options related to keys and shortcuts should respect it and fully support it (setting, finding, displaying, etc.). Please think through all cases so that the UI/UX is neat and complete. OK, I think the key search window can always show this modifier. When I have time, I'll check the other uses. Quote from: furious programming on October 07, 2024, 03:49:04 pmWait, an additional checkbox should always be visible, on every platform, so that you can select a combination with e.g. the Win key, without having to use the Grab key option. This is what my patch adds. Only for the flag with [Meta] to appear, you need to check the checkbox with "confirmation". Quote from: furious programming on October 07, 2024, 03:49:04 pmI've checked the changes and in my opinion, the proposed solution is over- engineered (that's my impression). Quote from: furious programming on October 07, 2024, 03:49:04 pmThe fourth checkbox should always be visible ... (without any confirmations). That's right. Simply displaying an additional modifier requires literally a few lines (or even one). Everything else in the corresponding commit is handling all possible use cases of the confirmation checkbox... (( I also feel offended by complicating things like that. If the developers agree to simply display this modifier, I will gladly remove the extra code. Thanks for the feedback. When I find time, I'll do it. For now, I've marked MR as a draft. ---------------------------------------------------------------------- flowCRANE · 2024-10-08 23:32 Ok, thanks everyone for the discussion! I have a hope that in the future I will be able to use shortcuts with the Win key. ---------------------------------------------------------------------- flowCRANE · 2024-10-14 18:23 @n7800: I checked your proposal on Windows 10, but after making these changes Lazarus cannot be compiled because errors appear. The problem is that you are using the TShortCutGrabBox.GetDefaultShiftButtons method as static (class method), even though it is a normal method (must be called from an object, not from a class). If I make this method static, Lazarus compiles correctly, but I can't use shortcuts with the Win key. The grab key dialog does not recognize shortcuts with the Win key at all, but if I set such a shortcut manually (by checking the Meta checkbox and selecting a key from the combobox), then such a shortcut will be accepted and saved by Lazarus, but it will not be detected by it. I have tested the combinations I care about, i.e. Win+Left/Right and Win+Shift+Left/Right, but neither is detected by the IDE. So your merge request must wait because your patch code needs to be fixed so that Lazarus can compile correctly. Secondly, something else needs to be programmed because Lazarus doesn't see the aforementioned Win key shortcuts. ---------------------------------------------------------------------- n7800 · 2024-10-18 01:36 Quote from: furious programming on October 14, 2024, 08:23:40 pm@n7800: I checked your proposal on Windows 10, but after making these changes Lazarus cannot be compiled because errors appear. The problem is that you are using the TShortCutGrabBox.GetDefaultShiftButtons method as static (class method), even though it is a normal method (must be called from an object, not from a class). If I make this method static, Lazarus compiles correctly, but I can't use shortcuts with the Win key. Can I ask how exactly you checked it? There are several commits in the request, in one of them I make this method a class method. I don't know your git skills, but a typical MR check includes (click the blue "Code" button on the MR page at the top right and select "Check out branch" for instructions): Code: Bash  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i git fetch "git@gitlab.com:n7800/lazarus.git" 'IDE/Options/Editor/KeyMap'git checkout -b 'lazarus-IDE/Options/Editor/KeyMap' FETCH_HEAD Or I recommend a simpler patch option - click the same blue button and select "Plain diff" to download the final patch (of all commits in MR) and apply it: Code: Bash  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i git apply Quote from: furious programming on October 14, 2024, 08:23:40 pmI have tested the combinations I care about, i.e. Win+Left/Right and Win+Shift+Left/Right, but neither is detected by the IDE. ... Secondly, something else needs to be programmed because Lazarus doesn't see the aforementioned Win key shortcuts. [Win+Left/Right] is used by the Windows to pin a window to half of the screen (try it on some regular window), and with [Shift] - to move a window between monitors. The OS will not allow any application to use these combinations. It is precisely about such restrictions that the checkbox should warn you )) I hope that you will still be able to find a sufficient number of free combinations for the actions you often use. I will soon take care of the remaining tasks (display Meta as Win, and always display it in the shortcut search window) to finish MR. ---------------------------------------------------------------------- Martin_fr · 2024-10-18 08:09 Quote from: n7800 on October 18, 2024, 03:36:20 am[Win+Left/Right] is used by the Windows to pin a window to half of the screen (try it on some regular window), and with [Shift] - to move a window between monitors. The OS will not allow any application to use these combinations. It is precisely about such restrictions that the checkbox should warn you )) And that is why I personally think the Win-Key should not be an (advertised) feature in the Keymap. If there is any (however minor) indication that the WinKey is a possible modifier for key combos, then people will expect it to work, always..., regardless of anything. If there is some warning, it will just lead to "Why did the makers of Lazarus disable that combo?". Yes, even if it says "It's Windows doing the restriction". It's a very human feature to ignore inconvenient info... ---- Personally, I don't mind if there is some backdoor-ish hack (like something compared to a registry key to change some Windows settings). But I wouldn't advertise adding it, because of the cost of maintenance. And because of it couldn't be guaranteed as future-safe. It may just disappear. (Yes,  I did read that it already exists... So, for those using it, lets hope it doesn't disappear) ---------------------------------------------------------------------- flowCRANE · 2024-10-18 10:54 Quote from: n7800 on October 18, 2024, 03:36:20 amCan I ask how exactly you checked it? There are several commits in the request, in one of them I make this method a class method. I applied these changes manually, in the sources of a normal Lazaurs installation (I don't use Git or trunk). If your fixes work for you, it means I forgot something, so it's my fault. I'll try again when I have some free time, this time I'll do it more carefully, so there's no misunderstanding. Quote[Win+Left/Right] is used by the Windows to pin a window to half of the screen (try it on some regular window), and with [Shift] - to move a window between monitors. The OS will not allow any application to use these combinations. However, both of these shortcuts do nothing on my computer (Win10, two monitors), so I wrongly assumed the system was not using them at all (so they are free). Again, my fault. QuoteIt is precisely about such restrictions that the checkbox should warn you )) Indeed. It's a pity that trying to capture a shortcut reserved by the system does not provide any feedback from Lazarus, so you never know why such a shortcut cannot be used. This is where it gets a bit complicated, because since the IDE does not receive messages about the shortcut being executed, there is no way to inform the user that the executed shortcut is reserved. To solve this and inform the user about which keyboard shortcuts are reserved, it would be good to check their list in Microsoft's documentation and provide access to this information in the IDE interface (maybe a button or link that opens documentation with a list of shortcuts and information about what the system uses them for), so that the user can familiarize themselves with this information. You can also add such link in the Grab key window. You would have to think about how to do it properly, i.e. on the one hand, it would be possible to assign shortcuts with the Meta key, and on the other hand, so that the user has access to information about which shortcuts are reserved by the OS (i.e. so that he does not have a grudge against the IDE developers that something does not work and does not consider it a bug). QuoteI hope that you will still be able to find a sufficient number of free combinations for the actions you often use. There are a lot of free shortcuts with the Win key — for example, I can use the Win+Alt+Left/Right shortcut to switch between editor tabs and the Win+Alt+Up/Down shortcut to switch between code editor windows. The system does not use shortcuts with the Win+Alt+ keys, so this should not be a problem. Quote from: Martin_fr on October 18, 2024, 10:09:45 amAnd that is why I personally think the Win-Key should not be an (advertised) feature in the Keymap. Just because something is difficult or troublesome doesn't mean you should give up. Especially since you've made an entire IDE and adapted it to various systems, which required a lot of work and dealing with system-specific things. QuoteIf there is some warning, it will just lead to "Why did the makers of Lazarus disable that combo?". Yes, even if it says "It's Windows doing the restriction". It's a very human feature to ignore inconvenient info... It will always be like this and there is nothing you can do about it, because if someone really doesn't want to acknowledge something, they won't. If you take care of supporting shortcuts with the Meta key, just describe their use and adapt the IDE interface to capture them, then you will do everything that needs to be done. So if someone reads the documentation and sees in the IDE that a given shortcut cannot be used because the IDE doesn't even receive data about its pressing, but still doesn't acknowledge it and has complaints, well — you can't conclude anything more than that such a user is simply an idiot and you can do nothing with it. This applies to all IDE features, not just the shortcut capturing discussed here. ---------------------------------------------------------------------- flowCRANE · 2024-10-18 12:09 If needed, adding support for Meta key shortcuts does not need to be implemented in the Lazarus sources — it can be in a separate package, installed optionally (like AnchorDockingDsgn for docked IDE, or metadarkstyle for the IDE's dark theme on Windows). ---------------------------------------------------------------------- flowCRANE · 2024-10-18 12:54 @n7800: I tried applying your commits again and everything is fine, the Win key shortcuts work fabulously! As I wrote above, I used the Win+Alt+Left/Right shortcuts for the Go to next/prior editor option and the Win+Alt+Up/Down shortcuts for the Go to next/prior window option — everything works correctly. There is one small problem with the Grab key window, after applying the changes. Regardless of whether the Allow use of Meta key checkbox is checked or not, pressing Esc closes the Grab key window and reopens it — only pressing Esc a second time closes the window and cancels grabbing the shortcut. Something is getting stuck in a loop, so canceling a second time opens the capture window — this should be easy to fix. This window behaves similarly when you capture a shortcut with the Win key — the first press of the shortcut is captured and the window closes, but it immediately appears a second time and I have to press the shortcut again. Do you have these problems or did I do something wrong again? ---------------------------------------------------------------------- n7800 · 2024-10-18 19:17 Quote from: Martin_fr on October 18, 2024, 10:09:45 amAnd that is why I personally think the Win-Key should not be an (advertised) feature in the Keymap. ... But I wouldn't advertise adding it, because of the cost of maintenance. I hear again that I'm supposedly "advertising" something... How can the phrase "OS dependent, no guarantee of functionality" be considered "advertising"? How can an additional click of the flag (with each editing of the shortcut!) be considered a call to action? I repeat, MR adds a warning. And prohibits the grab window from accepting combinations with invalid modifiers. And fixes a bug when the [Meta] checkbox was not visible, but it was checked. Quote from: Martin_fr on October 18, 2024, 10:09:45 amAnd because of it couldn't be guaranteed as future-safe. It may just disappear. (Yes,  I did read that it already exists... So, for those using it, lets hope it doesn't disappear) This is the Windows API, and I doubt that this will change. There are enough programs that use such combinations (for example, programs for custom virtual desktops, creating screenshots/screencast and other). In my program for keyboard shortcuts (written in Lazarus), I use many combinations with this key - that is, the OS allows you to register even global key combinations with it (which work even when the application is minimized to the tray). ---------------------------------------------------------------------- n7800 · 2024-10-18 19:37 Quote from: furious programming on October 18, 2024, 12:54:12 pmHowever, both of these shortcuts do nothing on my computer (Win10, two monitors) ... It's strange, I use them all the time (Win+Left/Right). Just curious, have you checked, for example, on the Explorer window? The grab window ignores these combinations, since it has no borders that allow resizing, but other windows should work. Quote from: furious programming on October 18, 2024, 12:54:12 pm... so I wrongly assumed the system was not using them at all (so they are free). I will probably add to the checkbox Hint that a good way to make sure is to press the combination in the grab window. If it catches the combination, then it should work in other IDE windows. Quote from: furious programming on October 18, 2024, 12:54:12 pmTo solve this and inform the user about which keyboard shortcuts are reserved, it would be good to check their list in Microsoft's documentation and provide access to this information in the IDE interface (maybe a button or link that opens documentation with a list of shortcuts and information about what the system uses them for), so that the user can familiarize themselves with this information. You can also add such link in the Grab key window. You would have to think about how to do it properly, i.e. on the one hand, it would be possible to assign shortcuts with the Meta key, and on the other hand, so that the user has access to information about which shortcuts are reserved by the OS (i.e. so that he does not have a grudge against the IDE developers that something does not work and does not consider it a bug). Informing about such a list is the task of the OS, and not all applications on the computer. In addition, even Microsoft does not always document everything it does. What can we say about other applications that can also intercept some combinations? I will not even say that Lazarus is cross-platform )) Quote from: furious programming on October 18, 2024, 02:09:55 pmIf needed, adding support for Meta key shortcuts does not need to be implemented in the Lazarus sources — it can be in a separate package, installed optionally (like AnchorDockingDsgn for docked IDE, or metadarkstyle for the IDE's dark theme on Windows). The last thing I want is to have separate packages for each checkbox... Also, for the package to communicate with the IDE, we need to add the appropriate interfaces. I don't know, but I think this will require even more code. Let me remind that we are talking about only one one checkbox (which is shown by default on MacOS)... ---------------------------------------------------------------------- n7800 · 2024-10-18 21:09 Quote from: furious programming on October 18, 2024, 02:54:12 pmThere is one small problem with the Grab key window, after applying the changes. Regardless of whether the Allow use of Meta key checkbox is checked or not, pressing Esc closes the Grab key window and reopens it — only pressing Esc a second time closes the window and cancels grabbing the shortcut. Something is getting stuck in a loop, so canceling a second time opens the capture window — this should be easy to fix. This window behaves similarly when you capture a shortcut with the Win key — the first press of the shortcut is captured and the window closes, but it immediately appears a second time and I have to press the shortcut again. This is already interesting. No wonder I can't reproduce it in trunk, otherwise I would have noticed right away )). Perhaps the problem is in applying a patch to an old version... I hope you can check the trunk, it will only take time to download and build (I have 5-10 minutes). You do not need to touch your existing installation. Code: Text  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i git clone "https://gitlab.com/freepascal.org/lazarus/lazarus.git" "S:\laztrunk"cd /d "S:\laztrunk"echo --pcp=config > lazarus.cfgmake clean alllazarus Of course, git and fpc must be installed. The third line creates a special IDE file, specifying to store all the configuration in the "config" subfolder, so this will be an isolated installation. Once Lazarus starts, install patch "git apply 346.diff" and rebuild as usual. ---------------------------------------------------------------------- flowCRANE · 2024-10-19 12:44 Quote from: n7800 on October 18, 2024, 09:37:55 pmIt's strange, I use them all the time (Win+Left/Right). Just curious, have you checked, for example, on the Explorer window? Yes. To be sure that this shortcut is not reserved, I've checked it on few normal system windows, File Explorer included. And this shortcut do nothing on my PC. The Win+Up/Down shortcuts are reserved and are used to minimize/restore any window but Win+Left/Right do nothing with windows. QuoteInforming about such a list is the task of the OS, and not all applications on the computer. Of course, but nothing stand in the way to provide a link to Microsoft/Apple/etc. documentation with such list. QuoteIn addition, even Microsoft does not always document everything it does. Well, in that case it is Microsoft's fault and we can do nothing with it (nothing more that an information that some shortcuts are reserved by the operating system). QuoteThe last thing I want is to have separate packages for each checkbox... Also, for the package to communicate with the IDE, we need to add the appropriate interfaces. I don't know, but I think this will require even more code. Let me remind that we are talking about only one one checkbox (which is shown by default on MacOS)... I know. But this proposition would apply only if official support of shortcuts with Meta key is rejected. In my opinion, support of such shortcuts should be implemented, because this significantly expands the pool of shortcuts thanks to which IDE operation can become more convenient and better adapted to the user's hardware (keyboard). Quote from: n7800 on October 18, 2024, 11:09:32 pmNo wonder I can't reproduce it in trunk, otherwise I would have noticed right away )). I've added this patch to a fresh Lazarus 3.6 install (latest stable release), and the sources are a bit different than the ones in trunk. If everything works fine for you (in trunk), then there's no point in delving into this. I've already set up my keyboard shortcuts and I won't be changing them anytime soon, so that's no problem. I can always analyze the sources and fix the problem myself. But for now, there's nothing to worry about.