rio icon indicating copy to clipboard operation
rio copied to clipboard

[Feature Request] Ctrl+K For Search

Open mahmedalam opened this issue 1 year ago • 5 comments

Description

Ctrl+K For Search

Suggested Solution

Simply Add My Script To Body

const handleKeyDown = (event) => {
  if ((event.ctrlKey || event.metaKey) && event.key === 'k') {
    event.preventDefault();
    input.focus();
  }
};

const input = document.querySelector(".rio-input-box-column input");
document.addEventListener('keydown', handleKeyDown);

Alternatives

No response

Additional Context

No response

Related Issues/Pull Requests

No response

mahmedalam avatar Nov 20 '24 23:11 mahmedalam

Thank you for always trying to provide solutions, but remember Rio is a Python framework. JavaScript & CSS aren't used on the Rio website.

mad-moo avatar Nov 21 '24 05:11 mad-moo

It'll probably be quite a while before we figure out how we want to handle keyboard shortcuts in rio, so I think we should (temporarily) solve this via JS. We could run the given JS code in on_session_start, using Session._evaluate_javascript.

Aran-Fey avatar Nov 21 '24 11:11 Aran-Fey

We don't have a high-level way of handling shortcuts, but neither has JavaScript. Any reason we can't handle this with a KeyEventListener?

mad-moo avatar Nov 21 '24 11:11 mad-moo

How would the KeyEventListener focus the search bar?

Aran-Fey avatar Nov 21 '24 11:11 Aran-Fey

I was responding to this

It'll probably be quite a while before we figure out how we want to handle keyboard shortcuts in Rio, so I think we should (temporarily) solve this via JS.

Btw, Ctrl+k doesn't normally focus the search, but rather open a sort of quick navigation. With that said, just focusing the search could be a quicak approximation of this behavior, that's much easier to create. Example from discord:

image

mad-moo avatar Nov 21 '24 17:11 mad-moo