Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom Keyboard Shortcuts #1553

Open
ThatOneCoder20 opened this issue Nov 29, 2024 · 4 comments
Open

Custom Keyboard Shortcuts #1553

ThatOneCoder20 opened this issue Nov 29, 2024 · 4 comments
Labels
enhancement New feature or request

Comments

@ThatOneCoder20
Copy link

Hello Chainlit Devs, is there any way for me to create custom keyboard shortcuts to perform certain functions, eg. alt + s will open the sidebar. Thx

@dosubot dosubot bot added the enhancement New feature or request label Nov 29, 2024
@dokterbob
Copy link
Collaborator

@dosu Any idea?

Copy link

dosubot bot commented Dec 3, 2024

You can create custom keyboard shortcuts in Chainlit by adding a keyboard event listener in your JavaScript code. Here's a basic example of how you might implement a custom shortcut, such as Alt + S to open a sidebar:

window.addEventListener("keydown", (e) => {
  if (e.altKey && e.key === "s") { // Custom shortcut: Alt + S
    // Your logic to open the sidebar
    console.log("Sidebar opened!");
  }
});

This code listens for the keydown event and checks if the Alt key and the S key are pressed simultaneously. You can replace the console.log with the actual function you want to trigger, such as opening a sidebar. This approach allows you to define any custom keyboard shortcuts you need.

To continue talking to Dosu, mention @dosu.

@ThatOneCoder20
Copy link
Author

ThatOneCoder20 commented Dec 4, 2024

@dosu That's only part of the code. I also need the logic to open the sidebar.

Copy link

dosubot bot commented Dec 4, 2024

A maintainer has already been looped in.

To continue talking to Dosu, mention @dosu.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants