Created
January 23, 2012 19:00
-
-
Save tcrayford/1664887 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from Quartz import * | |
import time as time | |
KEYCODES = { | |
#q12 | |
#w13 | |
#e14 | |
#r15 | |
#t17 | |
#y16 | |
#u32 | |
#i34 | |
#o31 | |
#p35 | |
#[33 | |
#]30 | |
#a0 | |
#s1 | |
#d2 | |
#f3 | |
#g5 | |
#h4 | |
#j38 | |
#k40 | |
#l37 | |
#;41 | |
#z6 | |
#x7 | |
#c8 | |
#v9 | |
#b11 | |
#n45 | |
#m46 | |
#,43 | |
#.47 | |
} | |
def callback(a,b,event,d): | |
print CGEventGetIntegerValueField(event, kCGKeyboardEventKeycode) | |
return None | |
tap = CGEventTapCreate( | |
kCGSessionEventTap, | |
kCGHeadInsertEventTap, | |
kCGEventTapOptionDefault, | |
CGEventMaskBit(kCGEventKeyDown) | CGEventMaskBit(kCGEventKeyUp), | |
callback, | |
1) | |
print callback | |
print tap | |
loop = CFMachPortCreateRunLoopSource(None, tap, 0) | |
CFRunLoopAddSource(CFRunLoopGetCurrent(), loop, kCFRunLoopCommonModes) | |
CGEventTapEnable(tap, True) | |
CFRunLoopRun() | |
time.sleep(1) | |
CFRelease(tap) | |
CFRunLoopStop() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment