Tracing Keybindings in Eclipse RCP

Tracing Keybindings in Eclipse RCP

When adding keybindings to an existing Eclipse RCP application, it is extremelly helpful to get realtime information about which keybinding registered and to what command handlers it is mapped to. Why is that?  Because sometimes the operating system or another widget will consume the keyboard event before it gets to the command framework. Other times there are several handlers bound to the same key causing a conflict.

Enabling Tracing for Keybindigs

Fortunatelly, this information is easy to get, if you enable the right tracing options:

org.eclipse.ui/debug = true
org.eclipse.ui/trace/keyBindings = true
org.eclipse.ui/trace/keyBindings.verbose = true


After that each keystroke will produce some output on the console:

KEYS --- WorkbenchKeyboard.executeCommand(commandId = 'org.eclipse.riena.navigation.ui.previousSubApplication', parameters = {})

In the above you can see that Ctrl+PageUp is mapped to the ‘previousSubApplication’ command.

Some times there is a conflict – i.e. one keybinding is mapped to two or more ‘active’ command handlers. This looks like this:

BINDINGS --- A conflict occurred for CTRL+SHIFT+W
BINDINGS ---     [Binding(CTRL+SHIFT+W,
	ParameterizedCommand(Command(org.eclipse.ui.file.closeAll,Close All,
		Close all editors,
	org.eclipse.ui.contexts.window,,,system), Binding(CTRL+SHIFT+W,
	ParameterizedCommand(Command(org.eclipse.riena.navigation.ui.closeModuleGroup,Close module group,
		Category(org.eclipse.riena.navigation.ui.swt,Riena Navigation Commands,null,true),

What happened here is that Ctrl+Shift+W was already bound to the CloseAllHandler via the ‘file.closeAll’ command. I was not aware of this initially, because it is defined in the org.eclipse.ui plugin. So I accidentally bound another command and handler to Ctrl+Shift+W. With the output I quickly realized what was going on. I ditched my own command and instead made ‘CloseModuleGroup’ a handler for the ‘file.closeAll’ command.

  • Posted at 5:43 pm, July 8, 2009

    Thanks, elias!

    I wasn’t aware of these tracing options. very helpful.

  • Posted at 9:08 am, July 9, 2009

    Thanks Elias,

    that is very useful. I used your information to describe this from the perspective of the Eclipse IDE, you find this here:

    I hope it is ok that I used your information.

  • Posted at 5:31 pm, July 9, 2009

    Hi Lars,

    No problem with citing this in your article. Thanks for the backlink. 🙂

  • eD
    Posted at 10:56 pm, July 29, 2010

    How about this issue, i execute a key binding and the action works( i can see it in the console and on screen). I do a few things inside my application, then try and do the exact same key binding and it shows it in the console, but no action is executed?

  • Posted at 7:53 pm, July 30, 2010

    @eD: hard to answer without looking at your code. My best guess: assuming you use commands and handlers – I would put breakpoints at the locations below and step through the code once you hit the key shortcut. The actual line numbers may differ if you are not on Eclipse 3.6.

    WorkbenchKeyboard [line: 435] – executeCommand(Binding, Event)
    Command [line: 457] – executeWithChecks(ExecutionEvent)

    I should also mention that we offer hourly developer support, where I and other Eclipse experts look at your code via screensharing and help out.

  • Adil
    Posted at 7:54 am, April 7, 2011


    Thanks for showing this tip.

    I am in the process of debugging why my rcp custom editor does not pick “Ctrl+1” quick fix key binding.
    The quick fix works from the right click menu but not by using the keyboard sequence. We lost this functionality as part of our upgrade from 3.3 to 3.6

    Thank you,