當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。