private void textBox_KeyDown(object sender, KeyRoutedEventArgs e) { // handle key presses if (e.Key == Windows.System.VirtualKey.Enter) { // do something when enter key is pressed } }
private void textBox_KeyUp(object sender, KeyRoutedEventArgs e) { // stop repeat keys if (e.KeyStatus.IsKeyReleased) { // key released, stop repeat behavior e.Handled = true; } }In this example, we handle the KeyUp event of a TextBox and check if the key status indicates that the key has been released. If it has, we set the Handled property of the event argument to true, which stops any repeat behavior for that key. The package library for KeyRoutedEventArgs is "Windows.UI.Xaml".