(self, c, scan, mods)
Insert a key-down event by eascii/unicode, scancode and modifiers.
Insert a key-down event by eascii/unicode, scancode and modifiers.
Insert a key - down event by eascii / unicode scancode and modifiers .
def _key_down(self, c, scan, mods):
        """Insert a key-down event by eascii/unicode, scancode and modifiers."""
        if scan is not None:
            self.last_scancode = scan
        # update ephemeral modifier status at every keypress
        # mods is a list of scancodes; OR together the known modifiers
        self.mod &= ~(
            MODIFIER[scancode.CTRL] | MODIFIER[scancode.ALT] |
            MODIFIER[scancode.LSHIFT] | MODIFIER[scancode.RSHIFT]
        )
        if mods:
            for m in mods:
                self.mod |= MODIFIER.get(m, 0)
        # set toggle-key modifier status
        # these are triggered by keydown events
        try:
            self.mod ^= TOGGLE[scan]
        except KeyError:
            pass
        # alt+keypad ascii replacement
        if mods and (scancode.ALT in mods):
            try:
                self.keypad_ascii += KEYPAD[scan]
                return
            except KeyError:
                pass
        if (
                self.mod & TOGGLE[scancode.CAPSLOCK]
                and not self._ignore_caps and len(c) == 1
            ):
            c = c.swapcase()
        self.buf.append(self._codepage.unicode_to_bytes(c), scan)
def _key_down ( self , c , scan , mods ) : if scan is not None : self . last_scancode = scan # update ephemeral modifier status at every keypress # mods is a list of scancodes; OR together the known modifiers self . mod &= ~ ( MODIFIER [ scancode . CTRL ] | MODIFIER [ scancode . ALT ] | MODIFIER [ scancode . LSHIFT ] | MODIFIER [ scancode . RSHIFT ] ) if mods : for m in mods : self . mod |= MODIFIER . get ( m , 0 ) # set toggle-key modifier status # these are triggered by keydown events try : self . mod ^= TOGGLE [ scan ] except KeyError : pass # alt+keypad ascii replacement if mods and ( scancode . ALT in mods ) : try : self . keypad_ascii += KEYPAD [ scan ] return except KeyError : pass if ( self . mod & TOGGLE [ scancode . CAPSLOCK ] and not self . _ignore_caps and len ( c ) == 1 ) : c = c . swapcase ( ) self . buf . append ( self . _codepage . unicode_to_bytes ( c ) , scan )