Click or drag to resize

KeyboardEventType Class

Localized message formatting class for a Unity keyboard event.
Inheritance Hierarchy
SystemObject
  KSPDev.GUIUtils.TypeFormattersKeyboardEventType

Namespace:  KSPDev.GUIUtils.TypeFormatters
Assembly:  KSPDev_Utils.2.0 (in KSPDev_Utils.2.0.dll) Version: 2.0 for KSP v1.8+
Syntax
C#
public sealed class KeyboardEventType
Request Example View Source

The KeyboardEventType type exposes the following members.

Constructors
  NameDescription
Public methodCode exampleKeyboardEventType
Constructs an object from an event.
Top
Methods
  NameDescription
Public methodStatic memberCode exampleFormat
Formats the value into a human friendly string.
Public methodToString
Returns a string formatted as a human friendly key specification.
(Overrides ObjectToString.)
Top
Operators
Fields
  NameDescription
Public fieldvalue
A wrapped event value.
Top
Remarks
Use it as a generic parameter when creating a LocalizableMessage descendants. Even though the name assumes it's only relevant to keyboard, it is not! A mouse or joystick action can also be a part of a "keyboard event", e.g. Ctrl + LMB.
Examples
public class KeyboardEventTypeDemo1 : PartModule {
  static readonly Message<KeyboardEventType> msg1 = new Message<KeyboardEventType>(
      "#TypeDemo_msg1", defaultTemplate: "Keybinding is [<<1>>]");

  // Depending on the current language in the system, this method will present different unit names. 
  void Show() {
    Debug.Log(msg1.Format(Event.KeyboardEvent("^1")));
    // Prints: Keybinding is [Ctrl+1]
    Debug.Log(msg1.Format(Event.KeyboardEvent("^[1]")));
    // Prints: Keybinding is [Ctrl+Alpha1]
    Debug.Log(msg1.Format(Event.KeyboardEvent("$^A")));
    // Prints: Keybinding is [Shift+Ctrl+A]
  }
}
See Also

Reference

KSPDev.GUIUtils.TypeFormattersKeyboardEventType