Table of Contents

Property HotKey

Namespace
Terminal.Gui
Assembly
Terminal.Gui.dll

HotKey

Gets or sets the hot key defined for this view. Pressing the hot key on the keyboard while this view has focus will invoke the HotKey and Accept commands. HotKey causes the view to be focused and Accept does nothing. By default, the HotKey is automatically set to the first character of Text that is prefixed with with HotKeySpecifier.

A HotKey is a keypress that selects a visible UI item. For selecting items across View`s (e.g.a Button in a Dialog) the keypress must include the WithAlt modifier. For selecting items within a View that are not Views themselves, the keypress can be key without the Alt modifier. For example, in a Dialog, a Button with the text of "_Text" can be selected with Alt-T. Or, in a Menu with "_File _Edit", Alt-F will select (show) the "_File" menu. If the "_File" menu has a sub-menu of "_New" `Alt-N` or `N` will ONLY select the "_New" sub-menu if the "_File" menu is already opened.

public virtual Key HotKey { get; set; }

Property Value

Key

Remarks

See ../docs/keyboard.md for an overview of Terminal.Gui keyboard APIs.

This is a helper API for configuring a key binding for the hot key. By default, this property is set whenever Text changes.

By default, when the Hot Key is set, key bindings are added for both the base key (e.g. D3) and the Alt-shifted key (e.g. D3. WithAlt). This behavior can be overriden by overriding AddKeyBindingsForHotKey(Key, Key).

By default, when the HotKey is set to A through Z key bindings will be added for both the un-shifted and shifted versions. This means if the HotKey is A, key bindings for Key.A and Key.A.WithShift will be added. This behavior can be overriden by overriding AddKeyBindingsForHotKey(Key, Key).

If the hot key is changed, the HotKeyChanged event is fired.

Set to Empty to disable the hot key.