Caps Lock as Modifier Key or using KANA Key

Share your favorite FastKeys commands
Post Reply
sindrijo
Posts: 1
Joined: Apr 4th, ’18, 10:49

Post by sindrijo » Apr 4th, ’18, 11:13

I would like to use the Caps-Lock key as a modifier key to bind some shortcuts, is that possible somehow?

Here are some examples of what I want:

Pressing Caps-Lock on its own should do nothing.

Caps-Lock + W => UP
Caps-Lock + A => LEFT
Caps-Lock + S => DOWN
Caps-Lock + D => RIGHT

Caps-Lock + Space => CTRL + BACKSPACE

Caps-Lock + J => CTLR + HOME
Caps-Lock + K => CTRL + LEFT
Caps-Lock + L => CTRL + RIGHT
Caps-Lock + [HRRP*] => CTRL + END

*[HRRP*] is the key that rests under your right pinky finger when you fingers are in the "home-row" position.

Additionally, adding ALT to any hotkey combination above should result in a SHIFT being added in the target hotkey combinations, for example:

Caps-Lock + ALT + J = CTRL + SHIFT + HOME
Etc...

I am currently achieving this by using a different program to create a custom keyboard layout that remaps the Caps-Lock key to KANA and then using AutoHotkey to achieve the hotkey combinations above (that is replacing Caps-Lock in the shortcuts described above with KANA)

The AutoHotkey script I am currently using is this, it includes some additional hotkeys not described above:

Code: Select all

;; CAPSLOCK FIX
SetCapsLockState, Off
SetCapsLockState, AlwaysOff

; SC03A  = KANA KEY
#InstallKeybdHook
; Visual Studio Binding: GoToFileMember
; CTRL+ALT+DOT
SC03A & t::
	Send, ^!.
return

; Delete with Shift+Backspace
SC03A & BackSpace::
+Backspace::
	Send {Delete}
return

;; Jump to Start of line or select to start of line
SC03A & n::
GetKeyState, state, Alt
if state = U
	Send {Home}
else
	Send +{Home}
return

; Jump to End of line or select to end of line
SC03A & o::
GetKeyState, state, Alt
if state = U
	Send {End}
else
	Send +{End}
return

; Seek or select to previous word boundary
SC03A & e::
#[::
GetKeyState, state, Alt
if state = U
	Send ^{Left}
else
	Send +^{Left}
return

; Seek or select to next word boundary
SC03A & i::
#]::
GetKeyState, state, Alt
if state = U
	Send ^{Right}
else
	Send +^{Right}
return

; Go to previous desktop
SC03A & q::
	Send ^#{Left}
return

; Go to next desktop
SC03A & f::
	Send ^#{Right}
return

;; CapsLock and space to erase last word
SC03A & Space::
	Send ^{Backspace}
return

;;
;; Arrow Key Navigation
;;
;; UP
SC03A & w::
	GetKeyState, ctrlState, Ctrl
	GetKeyState, altState, Alt
	if ctrlState = D
	{	
		Send ^{Up}
	}
	else if altState = D
	{
		Send !{Up}
	}
	else
	{
		Send {Up}
	}
return

;; DOWN
SC03A & r::
	GetKeyState, ctrlState, Ctrl
	GetKeyState, altState, Alt
	if ctrlState = D
	{	
		Send ^{Down}
	}
	else if altState = D
	{
		Send !{Down}
	}
	else
	{
		Send {Down}
	}
return

;; LEFT
SC03A & a::
	GetKeyState, ctrlState, Ctrl
	GetKeyState, altState, Alt
	if ctrlState = D
	{	
		Send ^{Left}
	}
	else if altState = D
	{
		Send +^{Left}
	}
	else
	{
		Send {Left}
	}
return

;; RIGHT
SC03A & s::
	GetKeyState, ctrlState, Ctrl
	GetKeyState, altState, Alt
	if ctrlState = D
	{	
		Send ^{Right}
	}
	else if altState = D
	{
		Send +^{Right}
	}
	else
	{
		Send {Right}
	}
return

#t::
ActiveHwnd := WinExist("A")
WinGetTitle, WindowTitle, ahk_id %ActiveHwnd%
WinGet, ExStyle, ExStyle, ahk_id %ActiveHwnd%
if (ExStyle & 0x8)
    OnTop=1
else
    OnTop=0
Winset, AlwaysOnTop, Toggle, ahk_id %ActiveHwnd%

StringReplace, WindowTitle, WindowTitle, %A_Space%- (Pinned)
if not OnTop
  WindowTitle:=WindowTitle . " - (Pinned)"
return

;; Media Keys

#Insert::
	Send {Media_Play_Pause}
return

#PgUp::
	Send {Volume_Up}
return

#PgDn::
	Send {Volume_Down}
return


#End::
	Send {Media_Stop}
	Send {Volume_Mute}
return
User avatar
Tom
Posts: 791
Joined: Nov 24th, ’15, 23:39

Post by Tom » Apr 4th, ’18, 14:52

In Shortcuts module, when entering a new item, double-click on a Shortcut field to enter a custom shortcut manually. You can enter the same commands you have in your script.

For example:
Shortcut: CapsLock & W
Type: Command

Code: Select all

GetKeyState, ctrlState, Ctrl
GetKeyState, altState, Alt
if ctrlState = D
   Send ^{Up}
else if altState = D
   Send !{Up}
else
   Send {Up}
return
Post Reply