question

HemalathaMarikumar-1823 avatar image
0 Votes"
HemalathaMarikumar-1823 asked ·

[UWP] While typing "6" in french keyboard it enters like "-6" in UWP Platforms

Hi Team,

I have a sample with entry/ numeric input controls. While changing the keyboard to France, while typing the 6 its turn into -6. Is that known issue? Could you please share any other workaround to resolve the same

windows-uwp
· 9
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

The problem only occurs in France keyboard right? have you tested with English key board?

0 Votes 0 ·

Yes. I have already ensured with English keyboard. That is worked fine

1 Vote 1 ·
NicoZhu-MSFT avatar image NicoZhu-MSFT HemalathaMarikumar-1823 ·

Ok, I got it, Please try press Shift + 6.

1 Vote 1 ·
NicoZhu-MSFT avatar image NicoZhu-MSFT HemalathaMarikumar-1823 ·

Do my reply make sense? And do you have any updates for this issue? If the the following solution solves your issue, you could accept it as answer. It could help others who are having the same issue.

0 Votes 0 ·
Show more comments

1 Answer

NicoZhu-MSFT avatar image
0 Votes"
NicoZhu-MSFT answered ·

Hello,

Welcome to Microsoft Q&A,

While typing "6" in french keyboard it enters like "-6" in UWP Platforms

Derive from official document, it's by-design within UWP input control for no-us keyboard layout. if you want to input number, you could switch to US-keyboard or press Shift + Number. And you could also use the following code the detect which key pressed then convert it to the char.


 private static char? ToChar(VirtualKey key, bool shift)
 {
       
     if (32 == (int)key)
         return ' ';
    
     VirtualKey search;
    
     
     foreach (var letter in "ABCDEFGHIJKLMNOPQRSTUVWXYZ")
     {
         if (Enum.TryParse<VirtualKey>(letter.ToString(), out search) && search.Equals(key))
             return (shift) ? letter : letter.ToString().ToLower()[0];
     }
    
     
     foreach (var number in "1234567890")
     {
         if (Enum.TryParse<VirtualKey>("Number" + number.ToString(), out search) && search.Equals(key))
             return number;
     }
    
      
     return null;
 }


Usage

 private void MyTextBox_KeyDown(object sender, KeyRoutedEventArgs e)
 {
     var c = ToChar(e.Key, false);
 }






·
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.