11

Is it possible in UWP to force it to open the On Screen Keyboard (osk.exe)?

For example, in C# it is possible using System.Diagnostics.Process.Start("osk.exe");

Doing the above in UWP results in compile error saying there is no Process namespace.

I know that in Tablet mode, if I programmatically focus on a TextBox, it will show up the OnScreen keyboard.

But is it possible when in Desktop mode?

Cœur
  • 37,241
  • 25
  • 195
  • 267
Water
  • 1,114
  • 1
  • 15
  • 31
  • Possible duplicate of [How to execute Process commands (or similar) using a Universal Windows Platform (UWP) App?](http://stackoverflow.com/questions/33925096/how-to-execute-process-commands-or-similar-using-a-universal-windows-platform) – James Gould Sep 21 '16 at 13:36
  • first of all, in tabletmode touchkeybord appears, not on-screen one. (Yes there is two of them) – ad1Dima Sep 21 '16 at 15:40
  • Oh I see, is there a way for touchkeyboard to appear in desktop mode? – Water Sep 22 '16 at 01:49
  • Hi Jay, I followed the link you gave and used BrokeredComponents. Worked for our app, thanks. – Water Sep 29 '16 at 03:59

2 Answers2

7

Is there a way for touchkeyboard to appear in desktop mode?

Ref the document in Keyboard interactions

Depending on the device, the touch keyboard appears when a text field or other editable text control gets focus, or when the user manually enables it through the Notification Center:
touch keyboard icon in the notification center
(source: s-msft.com)

Note The user might have to go to the Tablet mode screen in Settings > System and turn on "Make Windows more touch-friendly when using your device as a tablet" to enable the automatic appearance of the touch keyboard.

So the touch keyboard can appear automatically in tablet mode when users sets the input focus to a text control by using touch input. However, this won't happen in desktop mode and in UWP, there is no API to open it programmatically by now.

To show touch keyboard in desktop mode, we need the user manually enables it by clicking touch keyboard button and users can see this button by checking "Show touch keyboard button" in taskbar.
enter image description here

You are welcome to submit a request for this feature through UserVoice and Windows Feedback Hub app.

Glorfindel
  • 21,988
  • 13
  • 81
  • 109
Jay Zuo
  • 15,653
  • 2
  • 25
  • 49
  • So there's no way for an app to open and close the desktop's on-screen keyboard? Getting to the taskbar can be a bit of a pain when using a remote control to navigate a fullscreen app on a 4K television that's 12 feet away. – dynamichael Feb 18 '18 at 06:42
3

I was able to Show/Hide the On Screen Keyboard in Desktop Mode using:

CoreInputView.GetForCurrentView().TryShow(CoreInputViewKind.Keyboard)

Code Sample:

.xaml:

    <TextBox GotFocus="TextBox_OnGotFocus" LostFocus="TextBox_OnLostFocus" InputScope="Number"/>

.xaml.cs:

    private void TextBox_OnGotFocus(object _, RoutedEventArgs __)
    {
        CoreInputView.GetForCurrentView().TryShow(CoreInputViewKind.Keyboard);
    }

    private void TextBox_OnLostFocus(object _, RoutedEventArgs __)
    {
        CoreInputView.GetForCurrentView().TryHide();
    }

Additionally, you can control the keyboard type by setting the InputScope with values like: Number, NumericPin, Text, or others: https://learn.microsoft.com/en-us/uwp/api/Windows.UI.Xaml.Input.InputScopeNameValue

Jeremy Caney
  • 7,102
  • 69
  • 48
  • 77
Andrei
  • 61
  • 3