Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to hijack the Caps Lock key for Cut, Copy, Paste keyboard operations

Here is what I am trying to accomplish:

  1. To Copy, press and release Caps Lock ONCE
  2. To Paste, press and release Caps Lock TWICE, quickly
  3. To Cut, press Ctrl+Caps Lock

The reason I want to do this is often times i find my self looking down to press the correct X/C/V key, since they're all next to each other (atleast on a QWERTY keyboard).

How can I do this on a standard keyboard (using Windows), so that it applies to the entire system and is transparent to all applications, including to Windows Explorer? If not possible with a standard keyboard, can any of the "programmable numeric keypads" do this you think?

In the above, by "transparent" I mean "the application should never know that this keystroke was translated. It only gets the regular Ctrl+X/C/V code, so it behaves without any problems".

Ps. Not sure of all the tags that are appropriate for this question, so feel free to add more tags.

SOLVED. UPDATE: Thank you to @Jonno_FTW for introducing me to AutoHotKey. I managed all three requirements by adding the following AHK script in the default AutoHotKey.ahk file in My Documents folder:

Ctrl & CapsLock::
  Send ^x
Return      
CapsLock::
If (A_PriorHotKey = A_ThisHotKey and A_TimeSincePriorHotkey < 1000)
  Send ^v
Else
  Send ^c
Return

That was easy!

NOT COMPLETELY SOLVED. UPDATE: The above works in Notepad, but NOT in Explorer (copying files for example) or MS Office (even text copying does not work). So, I need to dig around a bit more into AutoHotKey or other solutions. Will post a solution here when I find one. In the meantime, if someone can make AutoHotKey work for everything I need, please reply!

ALL SOLVED. UPDATE: All I had to do was to change the capital "C"/X/Z to lowercase "c"/x/z. So Send ^C became Send ^c. It now works in ALL programs inlcuding Windows Explorer! Fixed code above to reflect this change.

like image 996
Liao Avatar asked Oct 11 '09 06:10

Liao


People also ask

Is there a shortcut to reverse Caps Lock?

The Caps Lock function can also be reversed by pressing Ctrl+Shift+Caps Lock. You can revert it to normal by pressing this combination of keys again.

How do I remap Caps Lock key?

Click the Keyboard icon in the System Preferences window. Click the Modifier Keys button near the bottom of the window and use the options here to change what your Caps Lock key does.

How do I turn off Caps Lock on virtual machine?

The Caps Lock key can sometimes become reversed in the virtual machine when Fusion is running. To resolve this issue, select Virtual Machine > Send Key > Caps Lock from the VMware Fusion menu bar.

How do I turn Caps Lock off on my Chromebook?

Press Search + Alt on your keyboard. When you're done, press the same keys to turn Caps Lock off again.


3 Answers

I believe the program you are looking for is AutoHotkey.

like image 64
Jonno_FTW Avatar answered Oct 13 '22 08:10

Jonno_FTW


You need a Global Keyboard Hook.

like image 43
Eric J. Avatar answered Oct 13 '22 06:10

Eric J.


Very nice! Been looking for something like this for a while.

My script is slightly different, making use of shift or control combinations for cut/copy, then CapsLock on its own is always paste.

Ctrl & CapsLock::
  Send ^x
Return

Shift & CapsLock::
  Send ^c
Return

CapsLock::
  Send ^v
Return

If you wanted to retain the option of retaining the Caps Lock function, I presume you could always remap e.g. Alt-CapsLock for this. I couldn't get it to toggle correctly when I tried it though.

like image 2
Steve Avatar answered Oct 13 '22 06:10

Steve