Pyloid Docs
GithubLanguage
  • 💎What is Pyloid?
  • Getting Started
    • Prerequisites
    • Create Pyloid App
  • Core Concepts
    • Thread Safety
  • API
    • Python (Backend)
      • Pyloid
      • BrowserWindow
      • Monitor
      • TrayEvent
      • Utility Functions
      • RPC
      • Store
    • Javascript (Frontend)
      • Event
      • BaseAPI
      • RPC
  • Guides
    • Load Webview
    • Serve Frontend
    • Calling Python from JS
    • Calling JS from Python
    • Keyboard Shotcuts
    • Notification
    • Tray
    • Timer
    • File Watcher
    • Clipboard
    • Window Position
    • Devtools
    • Window Drag Region
    • Window Radius And Transparent
    • Autostart
    • Production Utils
    • Desktop Monitor
    • File Dialog
    • Splash Screen
Powered by GitBook
On this page
  • Adding and Managing Shortcuts
  • Adding Shortcuts
  • Removing Shortcuts
  • Viewing All Shortcuts
  • Triggering Events

Was this helpful?

Edit on GitHub
  1. Guides

Keyboard Shotcuts

Adding and Managing Shortcuts

This section explains how to add and manage keyboard shortcuts in a Pyloid application.

Adding Shortcuts

You can add new shortcuts using the window.add_shortcut() method.

window.add_shortcut("shortcut", lambda: (action1, action2, ...))

Example:

window.add_shortcut("Ctrl+Shift+S", lambda: (
    print("Ctrl+Shift+S shortcut was pressed."),
))

Example using a regular function:

def handle_shortcut():
    print("Ctrl+Shift+F shortcut was pressed.")
    print("Current time:", datetime.now())

window.add_shortcut("Ctrl+Shift+F", handle_shortcut)

Removing Shortcuts

You can remove existing shortcuts using the window.remove_shortcut() method.

window.remove_shortcut("<shortcut>")

Example:

window.remove_shortcut("Ctrl+Shift+F")

Viewing All Shortcuts

You can view all currently registered shortcuts using the window.get_all_shortcuts()->Dict method.

Example:

print(window.get_all_shortcuts())

Triggering Events

You can trigger JavaScript events through shortcuts.

window.add_shortcut("shortcut", lambda: (
    window.emit('eventName', { "data": 'value' })
))

Example:

window.add_shortcut("Ctrl+Shift+E", lambda: (
    print("Ctrl+Shift+E shortcut was pressed."),
    window.emit('pythonEvent', { "message": 'Hello from Python!' })
))
PreviousCalling JS from PythonNextNotification

Last updated 29 days ago

Was this helpful?