Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

Sticky keys, just for shift and alphabetic characters


  • Please log in to reply
No replies to this topic
ori0n
  • Members
  • 2 posts
  • Last active: Aug 03 2018 04:16 PM
  • Joined: 15 Mar 2013

What it is
Sticky keys, but only for the shift key, and even then, only for characters you use when typing text.

Why I made it
I love sticky keys for typing (reduces my capitalization errors vs. holding shift), but when it's on, I find myself inadvertently activating Win key combos when trying to search in the Start menu. ("Win, L-I-S... oh, it logged me out.") This script is great for when I'm typing, but gets out of the way otherwise.

Notes

  • No 'lock' mode (a second shift press cancels the shift)
  • Doesn't get in the way of other combos (ctrl+a, alt+tab)
  • Timeout (so you don't accidentally leave shift pressed)
  • Doesn't interfere with holding shift

Examples
Shift, a => A
Shift, Shift, a => a
Shift + a => A
Shift, Shift + a => A
Shift, wait three sec, a => a
Shift, 8 => *

Shift, ] => ]
Shift, Ctrl+a => Select All
Shift, arrow key => moves cursor (doesn't select)
 
The code
 

;----------------
; Shift-alpha sticky keys
shiftablekeys = abcdefghijklmnopqrstuvwxyz1234567890.,'/ ; keys that respond to sticky shift
modifierkeys  = {LControl}{RControl}{LAlt}{RAlt}{LWin}{RWin}
Shift::
if AlreadyShifting { ; for two-shift cancellation
	AlreadyShifting = 0
	return
}
; Change or remove 'T2' to affect timeout of the sticky shift
Input, key, B M L1 T2, {LControl}{RControl}{LAlt}{LShift}{RShift}{RAlt}{LWin}{RWin}{AppsKey}{F1}{F2}{F3}{F4}{F5}{F6}{F7}{F8}{F9}{F10}{F11}{F12}{Left}{Right}{Up}{Down}{Home}{End}{PgUp}{PgDn}{Del}{Ins}{BS}{Capslock}{Numlock}{PrintScreen}{Pause}{Tab}{Space}
myerror := ErrorLevel
if InStr(myerror, "Shift") { ; if a second shift is received, cancel the existing one
	AlreadyShifting = 1
	SendPlay {Shift}
}
If InStr(myerror, "EndKey") { ; a non-printing end key
	StringReplace, key, myerror, EndKey:
}
if (myerror = "Timeout") {
	; Timeout, not sending anything
} else if (myerror = "Max") && StrLen(key) == 1 && InStr(shiftablekeys, key) {
	; Shifting
	SendPlay {Shift Down}{%key%}{Shift Up}
} else if InStr(modifierkeys, key) {
	; Modifier key detected; sending on so it still works as expected
	SendPlay {%key% Down}
} else {
	; Non-shiftable key: sending unmodified
	SendPlay {%key%}
}
Return

Known issues:
Shift, Alt+Tab yields legacy Alt+Tab menu (see http://superuser.com...windows-vista-7)