private void MessageToSend_OnPreviewKeyDown(object sender, KeyEventArgs e) { if (e.Key == Key.System) { var digit = KeyUtils.GetDigit(e.SystemKey); if (digit.HasValue) { _altMode = true; e.Handled = true; _altChar = (_altChar ?? 0) * 10 + digit.Value; } } }