on run argv set xkey to (item 1 of argv) if ((count of argv) > 1) then set xmod to (item 2 of argv) else set xmod to "" end if set xcode to 0 if xkey = "left" then set xcode to 123 if xkey = "right" then set xcode to 124 if xkey = "down" then set xcode to 125 if xkey = "up" then set xcode to 126 if xkey = "tab" then set xcode to 48 if xkey = "space" then set xcode to 49 if xkey = "enter" then set xcode to 76 if xkey = "backspace" then set xcode to 51 if xkey = "home" then set xcode to 115 if xkey = "end" then set xcode to 119 if xkey = "insert" then set xcode to 114 if xkey = "delete" then set xcode to 117 if xkey = "pgup" then set xcode to 116 if xkey = "pgdn" then set xcode to 121 if xkey = "esc" then set xcode to 53 if xmod = "" then if xcode = 0 then tell application "System Events" to keystroke xkey else tell application "System Events" to key code xcode end if else if xcode = 0 then if xmod = "c" then tell application "System Events" to keystroke xkey using control down if xmod = "o" then tell application "System Events" to keystroke xkey using option down if xmod = "s" then tell application "System Events" to keystroke xkey using shift down if xmod = "x" then tell application "System Events" to keystroke xkey using command down if xmod = "co" or xmod = "oc" then tell application "System Events" to keystroke xkey using {control down, option down} if xmod = "cs" or xmod = "sc" then tell application "System Events" to keystroke xkey using {control down, shift down} if xmod = "cx" or xmod = "xc" then tell application "System Events" to keystroke xkey using {control down, command down} if xmod = "os" or xmod = "so" then tell application "System Events" to keystroke xkey using {option down, shift down} if xmod = "ox" or xmod = "xo" then tell application "System Events" to keystroke xkey using {option down, command down} if xmod = "sx" or xmod = "xs" then tell application "System Events" to keystroke xkey using {shift down, command down} if xmod = "cos" or xmod = "cso" or xmod = "ocs" or xmod = "osc" or xmod = "sco" or xmod = "soc" then tell application "System Events" to keystroke xkey using {control down, option down, shift down} if xmod = "cox" or xmod = "cxo" or xmod = "ocx" or xmod = "oxc" or xmod = "xco" or xmod = "xoc" then tell application "System Events" to keystroke xkey using {control down, option down, command down} if xmod = "csx" or xmod = "cxs" or xmod = "scx" or xmod = "sxc" or xmod = "xcs" or xmod = "xsc" then tell application "System Events" to keystroke xkey using {control down, shift down, command down} if xmod = "osx" or xmod = "oxs" or xmod = "sox" or xmod = "sxo" or xmod = "xos" or xmod = "xso" then tell application "System Events" to keystroke xkey using {option down, shift down, command down} else if xmod = "c" then tell application "System Events" to key code xcode as integer using control down if xmod = "o" then tell application "System Events" to key code xcode as integer using option down if xmod = "s" then tell application "System Events" to key code xcode as integer using shift down if xmod = "x" then tell application "System Events" to key code xcode as integer using command down if xmod = "co" or xmod = "oc" then tell application "System Events" to key code xcode as integer using {control down, option down} if xmod = "cs" or xmod = "sc" then tell application "System Events" to key code xcode as integer using {control down, shift down} if xmod = "cx" or xmod = "xc" then tell application "System Events" to key code xcode as integer using {control down, command down} if xmod = "os" or xmod = "so" then tell application "System Events" to key code xcode as integer using {option down, shift down} if xmod = "ox" or xmod = "xo" then tell application "System Events" to key code xcode as integer using {option down, command down} if xmod = "sx" or xmod = "xs" then tell application "System Events" to key code xcode as integer using {shift down, command down} if xmod = "cos" or xmod = "cso" or xmod = "ocs" or xmod = "osc" or xmod = "sco" or xmod = "soc" then tell application "System Events" to key code xcode using {control down, option down, shift down} if xmod = "cox" or xmod = "cxo" or xmod = "ocx" or xmod = "oxc" or xmod = "xco" or xmod = "xoc" then tell application "System Events" to key code xcode using {control down, option down, command down} if xmod = "csx" or xmod = "cxs" or xmod = "scx" or xmod = "sxc" or xmod = "xcs" or xmod = "xsc" then tell application "System Events" to key code xcode using {control down, shift down, command down} if xmod = "osx" or xmod = "oxs" or xmod = "sox" or xmod = "sxo" or xmod = "xos" or xmod = "xso" then tell application "System Events" to key code xcode using {option down, shift down, command down} end if end if end run