# Class KeyBindingDispatcher

java.lang.Object
org.eclipse.e4.ui.bindings.keys.KeyBindingDispatcher

public class KeyBindingDispatcher extends Object

Controls the keyboard input into the workbench key binding architecture. This allows key events to be programmatically pushed into the key binding architecture -- potentially triggering the execution of commands. It is used by the `e4 Workbench` to listen for events on the `Display`.

## Nested Class Summary

Nested Classes
Modifier and Type
Class
Description
`final class`
`KeyBindingDispatcher.KeyDownFilter`
A display filter for handling key bindings.

## Constructor Summary

Constructors
Constructor
Description
`KeyBindingDispatcher()`

## Method Summary

Modifier and Type
Method
Description
`final boolean`
`executeCommand(ParameterizedCommand parameterizedCommand, Event trigger)`
Performs the actual execution of the command by looking up the current handler from the command manager.
`static List<KeyStroke>`
`generatePossibleKeyStrokes(Event event)`
Generates any key strokes that are near matches to the given event.
`final KeySequence`
`getBuffer()`
`KeyBindingDispatcher.KeyDownFilter`
`getKeyDownFilter()`
An accessor for the filter that processes key down and traverse events on the display.
`boolean`
`press(List<KeyStroke> potentialKeyStrokes, Event event)`
`void`
`resetState()`
`void`
`setContext(IEclipseContext context)`

### Methods inherited from class Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Constructor Details

### KeyBindingDispatcher

public KeyBindingDispatcher()

## Method Details

### generatePossibleKeyStrokes

public static List<KeyStroke> generatePossibleKeyStrokes(Event event)
Generates any key strokes that are near matches to the given event. The first such key stroke is always the exactly matching key stroke.

Parameters:
  `event` - The event from which the key strokes should be generated; must not be `null`.
Returns:
  The set of nearly matching key strokes. It is never `null`, but may be empty.

### executeCommand

public final boolean executeCommand(ParameterizedCommand parameterizedCommand, Event trigger) throws CommandException
Performs the actual execution of the command by looking up the current handler from the command manager. If there is a handler and it is enabled, then it tries the actual execution. Execution failures are logged. When this method completes, the key binding state is reset.

Parameters:
  `parameterizedCommand` - The command that should be executed; should not be `null`.
  `trigger` - The triggering event; may be `null`.
Returns:
  `true` if there was a handler; `false` otherwise.
Throws:
  `CommandException` - if the handler does not complete execution for some reason. It is up to the caller of this method to decide whether to log the message, display a dialog, or ignore this exception entirely.

### getKeyDownFilter

public KeyBindingDispatcher.KeyDownFilter getKeyDownFilter()
An accessor for the filter that processes key down and traverse events on the display.

Returns:
  The global key down and traverse filter; never `null`.

### press

public boolean press(List<KeyStroke> potentialKeyStrokes, Event event)

### resetState

public void resetState()

### getBuffer

public final KeySequence getBuffer()

### setContext

@Inject public void setContext(IEclipseContext context)