Skip to content

Instantly share code, notes, and snippets.

@jocap
Last active August 29, 2015 14:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jocap/0513775bb51d851e75a2 to your computer and use it in GitHub Desktop.
Save jocap/0513775bb51d851e75a2 to your computer and use it in GitHub Desktop.
The Space Cadet `Top` key for Windows. (Inspired by http://stevelosh.com/blog/2012/10/a-modern-space-cadet/#math)
; MathLayer.ahk
; Created by John Ankarström (jocap)
; Inspired by Steve Losh: http://stevelosh.com/blog/2012/10/a-modern-space-cadet/#math
; Compatible with US key layout
; Todo: Caps Lock support
; Issues: Selecting with LShift + arrow keys doesn't work great, RShift + arrow keys doesn't work at all
global MathMode := 0
Ins::
{
global MathMode
if (MathMode = 0) {
MathMode := 1
SoundBeep, 700
} else {
MathMode := 0
SoundBeep
}
return
}
a::
{
if (MathMode = 1) {
Send {U+2227}
} else {
Send {U+0061}
}
return
}
+a::
{
if (MathMode = 1) {
Send {U+2135}
} else {
Send {U+0041}
}
return
}
c::
{
if (MathMode = 1) {
Send {U+2218}
} else {
Send {U+0063}
}
return
}
+c::
{
if (MathMode = 1) {
Send {U+2102}
} else {
Send {U+0043}
}
return
}
e::
{
if (MathMode = 1) {
Send {U+2208}
} else {
Send {U+0065}
}
return
}
+e::
{
if (MathMode = 1) {
Send {U+2209}
} else {
Send {U+0045}
}
return
}
f::
{
if (MathMode = 1) {
Send {U+222B}
} else {
Send {U+0066}
}
return
}
i::
{
if (MathMode = 1) {
Send {U+2229}
} else {
Send {U+0069}
}
return
}
+i::
{
if (MathMode = 1) {
Send {U+221e}
} else {
Send {U+0049}
}
return
}
+n::
{
if (MathMode = 1) {
Send {U+2115}
} else {
Send {U+004E}
}
return
}
o::
{
if (MathMode = 1) {
Send {U+2228}
} else {
Send {U+006F}
}
return
}
r::
{
if (MathMode = 1) {
Send {U+221A}
} else {
Send {U+0072}
}
return
}
+r::
{
if (MathMode = 1) {
Send {U+211D}
} else {
Send {U+0052}
}
return
}
u::
{
if (MathMode = 1) {
Send {U+222A}
} else {
Send {U+0075}
}
return
}
x::
{
if (MathMode = 1) {
Send {U+22BB}
} else {
Send {U+0078}
}
return
}
+z::
{
if (MathMode = 1) {
Send {U+2124}
} else {
Send {U+005A}
}
return
}
-::
{
if (MathMode = 1) {
Send {U+00AC}
} else {
Send {U+002D}
}
return
}
=::
{
if (MathMode = 1) {
Send {U+2260}
} else {
Send {U+003D}
}
return
}
+::
{
if (MathMode = 1) {
Send {U+00B1}
} else {
Send {U+002B}
}
return
}
/::
{
if (MathMode = 1) {
Send {U+00F7}
} else {
Send {U+002F}
}
return
}
+,::
{
if (MathMode = 1) {
Send {U+2264}
} else {
Send {U+003C}
}
return
}
+.::
{
if (MathMode = 1) {
Send {U+2265}
} else {
Send {U+003E}
}
return
}
+8::
{
if (MathMode = 1) {
Send {U+00D7}
} else {
Send {U+002A}
}
return
}
0::
{
if (MathMode = 1) {
Send {U+2205}
} else {
Send {U+0030}
}
return
}
+`::
{
if (MathMode = 1) {
Send {U+2248}
} else {
Send {U+007E}
}
return
}
[::
{
if (MathMode = 1) {
Send {U+2282}
} else {
Send {U+005B}
}
return
}
+[::
{
if (MathMode = 1) {
Send {U+2284}
} else {
Send {U+007B}
}
return
}
^[::
{
if (MathMode = 1) {
Send {U+2286}
} else {
Send {RControl Down}[{RControl Up}
}
return
}
^+[::
{
if (MathMode = 1) {
Send {U+2288}
} else {
Send {RControl Down}{RShift Down}[{RShift Up}{RControl Up}
}
return
}
]::
{
if (MathMode = 1) {
Send {U+2283}
} else {
Send {U+005D}
}
return
}
+]::
{
if (MathMode = 1) {
Send {U+2285}
} else {
Send {U+007D}
}
return
}
^]::
{
if (MathMode = 1) {
Send {U+2287}
} else {
Send {RControl Down}]{RControl Up}
}
return
}
^+]::
{
if (MathMode = 1) {
Send {U+2289}
} else {
Send {RControl Down}{RShift Down}]{RShift Up}{RControl Up}
}
return
}
Left::
{
if (MathMode = 1) {
Send {U+2190}
} else {
Send {NumpadLeft}
}
return
}
+Left::
{
if (MathMode = 1) {
Send {U+219a}
} else {
Send {RShift Down}{NumpadLeft}{RShift Up}
}
return
}
^Left::
{
if (MathMode = 1) {
Send {U+21d0}
} else {
Send {RControl Down}{NumpadLeft}{RControl Up}
}
return
}
^+Left::
{
if (MathMode = 1) {
Send {U+21cd}
} else {
Send {RControl Down}{RShift Down}{NumpadLeft}{RShift Up}{RControl Up}
}
return
}
Right::
{
if (MathMode = 1) {
Send {U+2192}
} else {
Send {NumpadRight}
}
return
}
+Right::
{
if (MathMode = 1) {
Send {U+219b}
} else {
Send {RShift Down}{NumpadRight}{RShift Up}
}
return
}
^Right::
{
if (MathMode = 1) {
Send {U+21d2}
} else {
Send {RControl Down}{NumpadRight}{RControl Up}
}
return
}
^+Right::
{
if (MathMode = 1) {
Send {U+21cf}
} else {
Send {RControl Down}{RShift Down}{NumpadRight}{RShift Up}{RControl Up}
}
return
}
Up::
{
if (MathMode = 1) {
Send {U+2194}
} else {
Send {NumpadUp}
}
return
}
+Up::
{
if (MathMode = 1) {
Send {U+21ae}
} else {
Send {RShift Down}{NumpadUp}{RShift Up}
}
return
}
^Up::
{
if (MathMode = 1) {
Send {U+21d4}
} else {
Send {RControl Down}{NumpadUp}{RControl Up}
}
return
}
^+Up::
{
if (MathMode = 1) {
Send {U+21ce}
} else {
Send {RControl Down}{RShift Down}{NumpadUp}{RShift Up}{RControl Up}
}
return
}
Down::
{
if (MathMode = 1) {
Send {U+2194}
} else {
Send {NumpadDown}
}
return
}
+Down::
{
if (MathMode = 1) {
Send {U+21ae}
} else {
Send {RShift Down}{NumpadDown}{RShift Up}
}
return
}
^Down::
{
if (MathMode = 1) {
Send {U+21d4}
} else {
Send {RControl Down}{NumpadDown}{RControl Up}
}
return
}
^+Down::
{
if (MathMode = 1) {
Send {U+21ce}
} else {
Send {RControl Down}{RShift Down}{NumpadDown}{RShift Up}{RControl Up}
}
return
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment