Is there a way to disable keyboard accelerators for toolbar items?

With kde6 in apps like konsole and dolphin keyboard accelerators are now active for toolbar buttons with text, which interferes with readline key combos in konsole (Alt+F activates Find instead of moving cursor forward by a word). Is there a way to disable this behavior? Note that Enable menu accelerators is disabled in Konsole settings and the menu correctly doesn’t respond to Alt being pressed.

AFAIK there is currently no way to disable accelerators in the Konsole toolbar. It seems to me like the “Enable menu accelerators” setting should be expanded to also apply to the toolbar. Kate has already opted out of having accelerators for toolbars with ensure we don't have toolbar accelerators that clash with other stuff (7154bbd4) · Commits · Utilities / Kate · GitLab, a similar change could probably be applied to Konsole whenever “Enable menu accelerators” is disabled.

I see, thank you for the answer, I’ve just disabled the toolbar for now.

1 Like

See https://forum.manjaro.org/t/after-last-update-konsole-keyboard-shortcut-issue-with-alt-f/161923/13

Agree, there have been alot of complains about this recently (I think 2 bug reports, several reddit/discuss threads),

I tried this before, but was so far unfortunately unable to it.

There is KAcceleratorManager::setNoAccel(menuBar()); in MainWindow.cpp
which led me to believe I could do KAcceleratorManager::setNoAccel(toolBar());

That didn’t work at first, after I read your post I tried it again, and my issue was that I set it in the wrong line. If I set this in line 128 instead of 108, it works atleast for the main toolbar, but not for the session toolbar.

Also there is

void MainWindow::rememberMenuAccelerators()
{
    const QList<QAction *> actions = menuBar()->actions();
    for (QAction *menuItem : actions) {
        QString itemText = menuItem->text();
        menuItem->setData(itemText);
    }
}

// remove accelerators for standard menu items (eg. &File, &View, &Edit)
// etc. which are defined in kdelibs/kdeui/xmlgui/ui_standards.rc, again,
// to avoid conflicting with Alt+[Letter] terminal shortcuts
//
// TODO - Modify XMLGUI so that it allows the text for standard actions
// defined in ui_standards.rc to be re-defined in the local application
// XMLGUI file (konsoleui.rc in this case) - the text for standard items
// can then be redefined there to exclude the standard accelerators
void MainWindow::removeMenuAccelerators()
{
    const QList<QAction *> actions = menuBar()->actions();
    for (QAction *menuItem : actions) {
        menuItem->setText(menuItem->text().replace(QLatin1Char('&'), QString()));
    }
}

void MainWindow::restoreMenuAccelerators()
{
    const QList<QAction *> actions = menuBar()->actions();
    for (QAction *menuItem : actions) {
        QString itemText = menuItem->data().toString();
        menuItem->setText(itemText);
    }
}

which I guess makes “enable accelerator keys” option work.

TLDR: I can’t figure it out, but if some with programming skills wants to take a shot, the code should be in MainWindow.cpp

But completely disabling accelerator keys, which are part of assistive technologies almost on any platform, will create huge problems for people with disabilities, especially the ones relying too much on keyboard keys and find it hard to move hands or using mouse.

I guess thats why there is an option to disable it. So want/need them just don’t disable them.

If you think why not replace them with other keys: That was my first instinct too but I think its impossible.
Depending on your language you have other accelerator keys. Depending on your shell you might need other hotkeys.

1 Like

The most important part is: they should always be enabled by default on any application.

1 Like

I agree it should be enabled by default. Afaik currently it is not enabled by default.
It isn’t noticeable because the hamburger menu is used by default.

1 Like