Long press CapsLock act as Ctrl
-
- Posts: 2
- Joined: 22 Jul 2022, 22:06
- Contact:
Long press CapsLock act as Ctrl
Hello,
I am a bit of a noob with AHK. On Mac, I used Karabiner to make CapsLock (and Enter/Return) as follows.
* Single press works as CapsLock
* Ctrl works as usual. Its behavior is not changed.
* When CapsLock is long pressed along with another key, then it acts as Ctrl. (If long pressed and released without any other key pressed then it continues to act as CapsLock - this part is not mandatory per se)
Any help will be appreciated.
I am a bit of a noob with AHK. On Mac, I used Karabiner to make CapsLock (and Enter/Return) as follows.
* Single press works as CapsLock
* Ctrl works as usual. Its behavior is not changed.
* When CapsLock is long pressed along with another key, then it acts as Ctrl. (If long pressed and released without any other key pressed then it continues to act as CapsLock - this part is not mandatory per se)
Any help will be appreciated.
Re: Long press CapsLock act as Ctrl
Welcome to this AutoHotkey forum!
Perhaps:
Perhaps:
Code: Select all
*CapsLock::
SetKeyDelay -1
Send {Blind}{Ctrl DownR}
Return
*CapsLock Up::
SetKeyDelay -1
Send {Blind}{Ctrl up}
If (A_PriorKey = "CapsLock")
SetCapsLockState, % !GetKeyState("CapsLock", "T")
Return
-
- Posts: 3
- Joined: 31 Aug 2022, 22:38
Re: Long press CapsLock act as Ctrl
Hi,
Then how would you make it such that by holding down the capslock key it sends control, but by tapping the key still acts like a capslock?
Then how would you make it such that by holding down the capslock key it sends control, but by tapping the key still acts like a capslock?
Re: Long press CapsLock act as Ctrl
I would make it like I did. Here is what the script does.
* Single press works as CapsLock
* Ctrl works as usual. Its behavior is not changed.
* When CapsLock is long pressed along with another key, then it acts as Ctrl. (If long pressed and released without any other key pressed then it continues to act as CapsLock - this part is not mandatory per se)
* Single press works as CapsLock
* Ctrl works as usual. Its behavior is not changed.
* When CapsLock is long pressed along with another key, then it acts as Ctrl. (If long pressed and released without any other key pressed then it continues to act as CapsLock - this part is not mandatory per se)
Re: Long press CapsLock act as Ctrl
@mikeyww,
could you please explain this
And what does SetKeyDelay -1 in your answer to this question? I mean what is the importance of it in this context?
could you please explain this
It's not clear to me.SetKeyDelay says
When the delay is set to -1, a script's process-priority becomes an important factor in how fast it can send keystrokes when using the traditional SendEvent mode.
And what does SetKeyDelay -1 in your answer to this question? I mean what is the importance of it in this context?
Re: Long press CapsLock act as Ctrl
The script is adapted from the documentation. The -1 eliminates the usual delay after the key is sent. You can probably delete the line without any adverse effect in this setting.
-
- Posts: 2
- Joined: 22 Jul 2022, 22:06
- Contact:
Re: Long press CapsLock act as Ctrl
Thank you, @mikeyww. This has been working well. I would say 98% times. Sometimes it starts acting wonky. I am not able to replicate when it stops working, but I can exit and restart the shortcut, and it starts working again.
I have just disabled Sticky, Toggle, and Filter key and their shortcut. Let's see if it makes any difference.
Can this also be replicated for Enter/Return key with similar behavior?
* Single press enter key acts like enter.
* Simultaneous enter and another-key press acts like Ctrl.
This will help me use either of my pinky fingers for pressing Ctrl combination which is used a lot for text manipulation in Emacs.
I have just disabled Sticky, Toggle, and Filter key and their shortcut. Let's see if it makes any difference.
Can this also be replicated for Enter/Return key with similar behavior?
* Single press enter key acts like enter.
* Simultaneous enter and another-key press acts like Ctrl.
This will help me use either of my pinky fingers for pressing Ctrl combination which is used a lot for text manipulation in Emacs.
Re: Long press CapsLock act as Ctrl
Code: Select all
*Enter::Send {Blind}{Ctrl DownR} ; Use ENTER as Ctrl key
*Enter Up::
RegExMatch(A_ThisHotkey, "\*\K\S+", hk) ; Enter
Send % "{Blind}{Ctrl up}" (A_PriorKey = hk ? "{" hk "}" : "")
Return