User Interface / User Input / Keyboard Input
In This Topic
    Keyboard Input
    In This Topic
     About NKeyboard
    The NKeyboard static class manages the keyboard virtual device in NOV and serves as UI event dispatcher for native keyboard events, that a particular window peer receives. Following is a description of the keyboard related features and services:
     Events
    Event Description Event Arguments

    Keyboard Action Events

    NKeyboard.KeyDownEvent Raised when a keyboard key is pressed. The target is the current keyboard focus target. The event is routed along the entire route from the target node to its root.  NKeyEventArgs
    NKeyboard.KeyUpEvent Raised when a keyboard key is released. The target is the current keyboard focus target. The event is routed along the entire route from the target node to its root.  NKeyEventArgs
    NKeyboard.InputCharEvent Raised when a keyboard key(s) gesture is recognized as an Unicode input character. The target is the current keyboard focus target. The event is routed along the entire route from the target node to its root.  NInputCharEventArgs

    Keyboard Focus Target Events

    NKeyboard.GotFocusEvent Raised when the keyboard is focused on a specific target. Further Keyboard Action Events will be raised for the focus target until the keyboard focus is moved to another target. The event is routed along the entire route from the target node to its root.  NFocusChangeEventArgs
    NKeyboard.FocusInEvent Raised after NKeyboard.GotFocusEvent, but routed up to the last ancestor that was common between the previous focus target and the new one. NFocusChangeEventArgs
    NKeyboard.FocusOutEvent Raised before NKeyboard.LostFocusEvent, but routed up to the last ancestor that was common between the previous focus target and the new one. NFocusChangeEventArgs
    NKeyboard.LostFocusEvent Raised when a target looses keyboard focus. The event is routed along the entire route from the target node to its root.  NFocusChangeEventArgs
     Extended Properties
    Property Description
    NKeyboard.FocusedPropertyEx Set to true for the input target on which has the keyboard focus.
    NKeyboard.FocusWithinPropertyEx Set to true for the input target on which has the keyboard focus and all of its ancestors.
     Keyboard Focus
    Keyboard focus has two aspects – native and virtual. In order for an input target to actually gain keyboard focus, the peer of the window in which it resides must first gain native keyboard focus (i.e. the keyboard must first be focused in the native presentation layer). The part of the keyboard focus that deals with the actual window peer keyboard focus is referred as native keyboard focus. When native keyboard focus is obtained, all keyboard action events are natively routed to the window of the input target. Since NKeyboard is the front end for all keyboard events that arrive in NOV, it additionally redispatches the events to the current input target that has keyboard focus. This part of keyboard focus is referred as virtual keyboard focus, since the native presentation layer plays no role in this process. You typically never deal directly with the keyboard focus abilities of NKeyboard, but rather use the methods of the class (see Input Elements for more info).
     Ambient Information

    At any time you can obtain the state of the modifier keys (Ctrl, Alt and Shift), via the following properties:

    • NKeyboard.ShiftPressed – returns true if the Shift is pressed
    • NKeyboard.ShiftPressedAlone - returns true if the Shift is the only pressed modifier
    • NKeyboard.AltPressed – returns true if the Alt is pressed
    • NKeyboard.AltPressedAlone - returns true if the Alt is the only pressed modifier
    • NKeyboard.CtrlPressed - returns true if the Ctrl is pressed
    • NKeyboard.CtrlPressedAlone - returns true if the Ctrl is the only pressed modifier
    • NKeyboard.PressedModifiers – returns the pressed modifiers as a masked enum

     

    The NKeyboard also provides several methods for helping you obtain the current value of the extended properties that it has applied to a particular node. These are:

    • NKeyboard.IsFocused(NNode node) – returns the current value of the NKeyboard.FocusedPropertyEx extended property for the specified node.
    • NKeyboard.IsFocusWithin(NNode node) – returns the current value of the NKeyboard.FocusWithinPropertyEx extended property for the specified node.