Search Results for

Show / Hide Table of Contents

# Class ShortcutHelper

Represents a helper to manipulate shortcut keys used on views.

##### Inheritance

System.Object
ShortcutHelper

###### Namespace: Terminal.Gui

###### Assembly: Terminal.Gui.dll

##### Syntax

    public class ShortcutHelper : Object

### Constructors

#### ShortcutHelper()

##### Declaration

    public ShortcutHelper()

### Properties

#### Shortcut

This is the global setting that can be used as a global shortcut to invoke the action on the view.

##### Declaration

    public virtual Key Shortcut { get; set; }

##### Property Value

Type | Description
--- | ---
Key |

#### ShortcutAction

The action to run if the Shortcut is defined.

##### Declaration

    public virtual Action ShortcutAction { get; set; }

##### Property Value

Type | Description
--- | ---
System.Action |

#### ShortcutTag

The keystroke combination used in the Shortcut as string.

##### Declaration

    public virtual ustring ShortcutTag { get; }

##### Property Value

Type | Description
--- | ---
NStack.ustring |

### Methods

#### CheckKeysFlagRange(Key, Key, Key)

Lookup for a Key on range of keys.

##### Declaration

    public static bool CheckKeysFlagRange(Key key, Key first, Key last)

##### Parameters

Type | Name | Description
--- | --- | ---
Key | key | The source key.
Key | first | First key in range.
Key | last | Last key in range.

##### Returns

Type | Description
--- | ---
System.Boolean |

#### FindAndOpenByShortcut(KeyEvent, View)

Allows a view to run a ShortcutAction if defined.

##### Declaration

    public static bool FindAndOpenByShortcut(KeyEvent kb, View view = null)

##### Parameters

Type | Name | Description
--- | --- | ---
KeyEvent | kb | The KeyEvent
View | view | The View

##### Returns

Type | Description
--- | ---
System.Boolean | `true` if defined `false`otherwise.

#### GetKeyToString(Key, out Key)

Return key as string.

##### Declaration

    public static ustring GetKeyToString(Key key, out Key knm)

##### Parameters

Type | Name | Description
--- | --- | ---
Key | key | The key to extract.
Key | knm | Correspond to the non modifier key.

##### Returns

Type | Description
--- | ---
NStack.ustring |

#### GetModifiersKey(KeyEvent)

Gets the key with all the keys modifiers, especially the shift key that sometimes have to be injected later.

##### Declaration

    public static Key GetModifiersKey(KeyEvent kb)

##### Parameters

Type | Name | Description
--- | --- | ---
KeyEvent | kb | The KeyEvent to check.

##### Returns

Type | Description
--- | ---
Key | The Key with all the keys modifiers.

#### GetShortcutFromTag(ustring, ustring)

Allows to retrieve a Key from a ShortcutTag

##### Declaration

    public static Key GetShortcutFromTag(ustring tag, ustring delimiter = null)

##### Parameters

Type | Name | Description
--- | --- | ---
NStack.ustring | tag | The key as string.
NStack.ustring | delimiter | The delimiter string.

##### Returns

Type | Description
--- | ---
Key |

#### GetShortcutTag(Key, ustring)

Get the Shortcut key as string.

##### Declaration

    public static ustring GetShortcutTag(Key shortcut, ustring delimiter = null)

##### Parameters

Type | Name | Description
--- | --- | ---
Key | shortcut | The shortcut key.
NStack.ustring | delimiter | The delimiter string.

##### Returns

Type | Description
--- | ---
NStack.ustring |

#### PostShortcutValidation(Key)

Used at key up validation.

##### Declaration

    public static bool PostShortcutValidation(Key key)

##### Parameters

Type | Name | Description
--- | --- | ---
Key | key | The key to validate.

##### Returns

Type | Description
--- | ---
System.Boolean | `true` if is valid.`false`otherwise.

#### PreShortcutValidation(Key)

Used at key down or key press validation.

##### Declaration

    public static bool PreShortcutValidation(Key key)

##### Parameters

Type | Name | Description
--- | --- | ---
Key | key | The key to validate.

##### Returns

Type | Description
--- | ---
System.Boolean | `true` if is valid.`false`otherwise.