Need to prevent OS interception of some keyboard shortcuts in my tui-rs + crossterm app

Hi everyone,

I faced with an issue in my tui-rs + crossterm app, when some keyboard combinations which I want to use are OS-defined shortcuts and are intercepted by OS, so this way this combinations not work for my app. For example:

KeyCode::Up if key_modifiers.contains(KeyModifiers::CONTROL) => {
    if self.scroll_offset > 0 {
        self.scroll_offset -= 1;
    }
},

this is not work for macOS. Or if I want to use Ctrl + 1 this will not work for Linux.

Could somebody explain if it possible to let my app to prevent OS interception, or probably this issue can be fixed on other way ?

That sounds like it's not the OS, it's likely your window manager or terminal application. For example if you wanted to "see" Alt + 1 while running your app in Gnome terminal, you'd have to disable the corresponding shortcut.

The process is going to differ based on which software you're running in. There's no general way to force it from your app.

2 Likes

so in case I want to run my app from terminal, the best way will be to implement some fallback shortcuts ? to make it possible to work from multiple terminals

1 Like

That sounds like a reasonable option. Another (complementing) approach is to make your own shortcuts configurable.

2 Likes

Thank you for your answer.

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.