Skip to content

Instantly share code, notes, and snippets.

@okay-type
Forked from connordavenport/WASD.py
Last active March 18, 2021 16:41
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 okay-type/03fd0544dda20b05cadb0cb3d9c81a8a to your computer and use it in GitHub Desktop.
Save okay-type/03fd0544dda20b05cadb0cb3d9c81a8a to your computer and use it in GitHub Desktop.
Convert arrow functions to ASWD keys in the glyphView. If you have shortcuts already set up for any of these keys you will run into issues!
from mojo.subscriber import Subscriber, registerRoboFontSubscriber
from mojo.events import extractNSEvent
class KeyTest(Subscriber):
debug = True
def build(self):
if self.debug == True:
print('KeyTest', 'build!')
def destroy(self):
if self.debug == True:
print('KeyTest', 'destroy!')
def glyphEditorKeyDown(self, notification):
info = notification['lowLevelEvents'][0]
characters = info['event'].characters()
shiftDown = extractNSEvent(info)['shiftDown']
commandDown = extractNSEvent(info)['commandDown']
capLockDown = extractNSEvent(info)['capLockDown']
optionDown = extractNSEvent(info)['optionDown']
controlDown = extractNSEvent(info)['controlDown']
locationInWindow = notification['iterations'][0]['deviceState']['locationInWindow']
locationInView = notification['iterations'][0]['deviceState']['locationInView']
print('KeyTest characters:', characters)
print('KeyTest shiftDown:', shiftDown)
print('KeyTest commandDown:', commandDown)
print('KeyTest capLockDown:', capLockDown)
print('KeyTest optionDown:', optionDown)
print('KeyTest controlDown:', controlDown)
print('KeyTest locationInWindow:', locationInWindow)
print('KeyTest locationInView:', locationInView)
registerRoboFontSubscriber(KeyTest)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment