Exemple #1
0
 def on_press(self, key):
     if len(self.key_identifier) == 1:
         if key == KeyCode(char=self.key_identifier):
             return False
     elif key == Key(self.key_identifier):
         if key == KeyCode(char=self.key_identifier):
             return False
Exemple #2
0
    def __init__(self, key):
        """Initialize ARKey class."""
        self.isctrl = False
        self.ischar = False

        if isinstance(key, (Key, KeyCode)):
            self.isctrl = (key == Key.ctrl_l) or (key == Key.ctrl_r)
            self.key = key

        elif isinstance(key, int):
            try:
                self.key = Key(KeyCode.from_vk(key))

            except ValueError:
                self.key = KeyCode.from_vk(key)

        elif isinstance(key, str):
            self.key = KeyCode.from_char(key)
Exemple #3
0
def on_release(key):
    if hasattr(key, attr[0]):
        print time.time(), 1, key.char

    elif hasattr(key, attr[1]) or hasattr(key, attr[2]) or hasattr(key, attr[3]) or hasattr(key, attr[4]):
        k = ('{0}'.format(key))
        z = k.split('.')
        print time.time(), 1, z[1]

class Key (threading.Thread):

    def run(self):

        with Listener(
                on_press=on_press,
                on_release=on_release) as listener:
            listener.join()

if __name__ == '__main__':

    config    = CONFIG('.')

    play = Play()
    key = Key()
    play.start()
    key.start()

    play.join()
    key.join()