Udostępnij za pośrednictwem


UIElement.CharacterReceived Event

Definition

Occurs when a single, composed character is received by the input queue.

// Register
event_token CharacterReceived(TypedEventHandler<UIElement, CharacterReceivedRoutedEventArgs const&> const& handler) const;

// Revoke with event_token
void CharacterReceived(event_token const* cookie) const;

// Revoke with event_revoker
UIElement::CharacterReceived_revoker CharacterReceived(auto_revoke_t, TypedEventHandler<UIElement, CharacterReceivedRoutedEventArgs const&> const& handler) const;
public event TypedEventHandler<UIElement,CharacterReceivedRoutedEventArgs> CharacterReceived;
function onCharacterReceived(eventArgs) { /* Your code */ }
uIElement.addEventListener("characterreceived", onCharacterReceived);
uIElement.removeEventListener("characterreceived", onCharacterReceived);
- or -
uIElement.oncharacterreceived = onCharacterReceived;
Public Custom Event CharacterReceived As TypedEventHandler(Of UIElement, CharacterReceivedRoutedEventArgs) 
<uiElement CharacterReceived="eventhandler"/>

Event Type

Windows requirements

Device family
Windows 10 Fall Creators Update (introduced in 10.0.16299.0)
API contract
Windows.Foundation.UniversalApiContract (introduced in v5.0)

Remarks

Note

A composed character is a single visual object derived from a sequence of one or more other characters.

CharacterReceived is a routed event. For more info on the routed event concept, see Events and routed events overview.

Apps do not receive this event when an Input Method Editor (IME) is enabled. The Input Method Editor (IME) handles all keyboard input and sets Handled to true.

This event is useful for text input scenarios such as "typeahead find or search" (also known as incremental search, incremental find, or real-time suggestions) where, as the user types, the control progressively searches for and filters text based on the characters in the input queue.

The CharacterReceived event can occur at different times depending on the character entered, as the event is not fired until the composed character is registered in the input queue.

  • User presses the W key (the character 'w' is received):
    • PreviewKeyDown for W
    • KeyDown for W
    • CharacterReceived
    • PreviewKeyUp for W
    • KeyUp for W
  • User presses the Shift+W keys (the character 'W' is received):
    • PreviewKeyDown for Shift
    • KeyDown for Shift
    • PreviewKeyDown for W
    • KeyDown for W
    • CharacterReceived
    • PreviewKeyUp for W
    • KeyUp for W
    • PreviewKeyUp for Shift
    • KeyUp for Shift
  • User presses Alt+164 using the NumPad (the character ‘ñ’ is received):
    • PreviewKeyDown for Alt
    • KeyDown for Alt
    • PreviewKeyDown for 1
    • KeyDown for 1
    • PreviewKeyUp for 1
    • KeyUp for 1
    • PreviewKeyDown for 6
    • KeyDown for 6
    • PreviewKeyUp for 6
    • KeyUp for 6
    • PreviewKeyDown for 4
    • KeyDown for 4
    • PreviewKeyUp for 4
    • KeyUp for 4
    • CharacterReceived
    • PreviewKeyUp for Alt
    • KeyUp for Alt

Applies to

See also