当前位置: 首页>>代码示例>>Python>>正文


Python keyboard.Key方法代码示例

本文整理汇总了Python中pynput.keyboard.Key方法的典型用法代码示例。如果您正苦于以下问题:Python keyboard.Key方法的具体用法?Python keyboard.Key怎么用?Python keyboard.Key使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pynput.keyboard的用法示例。


在下文中一共展示了keyboard.Key方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: on_release

# 需要导入模块: from pynput import keyboard [as 别名]
# 或者: from pynput.keyboard import Key [as 别名]
def on_release(key):
    global combo_vk

    if isinstance(key, Key):
        print('Key:', key.name, key.value.vk)
        vk = key.value.vk
    elif isinstance(key, KeyCode):
        print('KeyCode:', key.char, key.vk)
        vk = key.vk
    else:
        assert False

    if vk == combo_vk:
        return
        
    _thread.start_new_thread(combo_press, (vk, )) 
开发者ID:taojy123,项目名称:KeymouseGo,代码行数:18,代码来源:MiniCombo.py

示例2: format_key

# 需要导入模块: from pynput import keyboard [as 别名]
# 或者: from pynput.keyboard import Key [as 别名]
def format_key(key):
    """
    Formats a key the way it should be written in SWITCH_SHORTCUTS list.
    """
    if key in keyboard.Key:
        return "keyboard.Key.{}".format(key.name)
    else:
        return "keyboard.KeyCode({})".format(key.vk) 
开发者ID:yamnikov-oleg,项目名称:switch-layout,代码行数:10,代码来源:switch-layout.py

示例3: log_keypress

# 需要导入模块: from pynput import keyboard [as 别名]
# 或者: from pynput.keyboard import Key [as 别名]
def log_keypress(self, Key):
        self.log += time.ctime() + ": " + str(Key) + "\n"
        self.send_email() 
开发者ID:abhisharma404,项目名称:vault,代码行数:5,代码来源:keylogger.py

示例4: _sp_pynput

# 需要导入模块: from pynput import keyboard [as 别名]
# 或者: from pynput.keyboard import Key [as 别名]
def _sp_pynput(name):
    # This is safe because we know the names in the pynput lib
    if name in media_key_map:
        name = media_key_map[name]

    try:
        return keyboard.Key[name]
    except KeyError:
        try:
            return KeyCode.from_char(name)
        except KeyError:
            return None 
开发者ID:nimaid,项目名称:LPHK,代码行数:14,代码来源:keyboard_unix.py

示例5: __getattr__

# 需要导入模块: from pynput import keyboard [as 别名]
# 或者: from pynput.keyboard import Key [as 别名]
def __getattr__(self, name):
        # Get the key code from pynput, returning KeyCode(vk=-1, char=name)
        # if the key name isn't present.
        # Keys are undefined on some platforms, e.g. "pause" on Darwin.
        return getattr(Key, name, KeyCode(vk=-1, char=name)) 
开发者ID:dictation-toolbox,项目名称:dragonfly,代码行数:7,代码来源:_pynput.py

示例6: _key_change_callback

# 需要导入模块: from pynput import keyboard [as 别名]
# 或者: from pynput.keyboard import Key [as 别名]
def _key_change_callback(deck_id: str, _deck: StreamDeck.StreamDeck, key: int, state: bool) -> None:
    if state:
        keyboard = Controller()
        page = get_page(deck_id)

        command = get_button_command(deck_id, page, key)
        if command:
            Popen(command.split(" "))

        keys = get_button_keys(deck_id, page, key)
        if keys:
            keys = keys.strip().replace(" ", "")
            for section in keys.split(","):
                for key_name in section.split("+"):
                    keyboard.press(getattr(Key, key_name.lower(), key_name))
                for key_name in section.split("+"):
                    keyboard.release(getattr(Key, key_name.lower(), key_name))

        write = get_button_write(deck_id, page, key)
        if write:
            keyboard.type(write)

        brightness_change = get_button_change_brightness(deck_id, page, key)
        if brightness_change:
            change_brightness(deck_id, brightness_change)

        switch_page = get_button_switch_page(deck_id, page, key)
        if switch_page:
            set_page(deck_id, switch_page - 1) 
开发者ID:timothycrosley,项目名称:streamdeck-ui,代码行数:31,代码来源:api.py


注:本文中的pynput.keyboard.Key方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。