示例#1
0
    def keycode(self, name, is_dead):
        """Resolves a key description to a value that can be passed to
        :meth:`pynput.keyboard.Controller.press` and
        :meth:`~pynput.keyboard.Controller.release`.

        :param str name: The name of the key. This should typically be the
            actual character requested. If it starts with ``'<'`` and ends with
            ``'>'``, the key value is looked up in
            :class:`pynput.keyboard.Key`, otherwise it is passed straight to
            :meth:`pynput.keyboard.Controller.press`.

        :return: a key value
        """
        if is_dead:
            return KeyCode.from_dead(name)
        elif name[0] == '<' and name[-1] == '>':
            return Key[name[1:-1]]
        else:
            return name