keyboard.py

"""Prints pressed keys to the screen.
   by stephan)
"""
from slut import *

class Atlantis(World):
    def onSetup(self):
        self.name = "Mouse"
        self.key = ''
        self.font = font(34, 'arial')

    def onKeyDown(self, event):
        #check whether key is a valid character
        if event.key in range(256):
            #convert ascii to string
            self.key = chr(event.key)

    def onDrawOrtho(self):
        text(self.key, self.font, 190, 200)


atlantis = Atlantis()
atlantis.run()
Initiated by Stephan Hechenberger
Thanks to CADRE's 103