Hooking up the command to a keystroke requires a KeyBinding. This allows a key (or series of keys) to be used to invoke the command instead of only via the menu. KeyBindings are set up inside a Binding Table and associated with a Binding Context.
fragment.e4xmi
in the clock.ui
project.org.eclipse.ui.contexts.dialogAndWindow
context:org.eclipse.e4.legacy.ide.application
bindingTables
org.eclipse.ui.contexts.dialogAndWindow
context. This will ensure that the key binding is available in all windows and dialogs:M1+9
. Next to the Command, click on Find... and choose the Hello command:The M1 key is the primary meta key, which is Cmd on macOS and Ctrl on Windows/Linux. This is typically used for the main operations; for example, M1+C
is copy and M1+V
is paste on all systems. The sequence notation M1+9
is used to indicate pressing both keys at the same time.
The command that gets invoked is referenced by its commandId
. This may be defined in the same plug-in, but it does not have to be; it is possible for one application to provide a set of commands and another plug-in to provide keystrokes that bind them.
It is also possible to set up a sequence of key presses; for example, M1+9 8 7
would require pressing Cmd (or Ctrl) with 9
followed by 8
and then 7
before the command is executed. This allows a set of keystrokes to be used to invoke a command; for example, it's possible to emulate an Emacs quit operation with the KeyBinding Ctrl + X Ctrl + C to the quit
command.
Other modifier keys include M2
(Shift), M3
(Alt or Option), and M4
(Ctrl on macOS). It is possible to use CTRL
, SHIFT
or ALT
as long names but the meta names are preferred, since M1
tends to be bound to different keys on different operating systems.
The non-modifier keys themselves can either be single characters (A-Z
), numbers (0-9
), or one of a set of longer name key-codes such as F12
, ARROW_UP
, TAB
, and PAGE_UP
. Certain common variations are allowed, for example, ESC
/ESCAPE
and ENTER
/RETURN
.
3.136.22.50