locked
how to know if there is a real keyboard. like "Surface"

    Question

  • How to know if there is a real keyboard?

    If there is one connected, I needn't to activate the virtual keyboard with UIA.


    C++ DX11

    Tuesday, June 19, 2012 2:06 AM

Answers

  • You should set the appropriate UIA properties and events regardless of whether there is a physical keyboard or not. The soft-keyboard will show only if the user tried to activate it by touching your text control.

    That said, you can check for a keyboard with Windows.Devices.Input.KeyboardCapabilities.KeyboardPresent.

    --Rob

    • Marked as answer by Raptor K Tuesday, June 19, 2012 2:25 AM
    Tuesday, June 19, 2012 2:08 AM
    Owner
  • KeyboardPresent will return false if there isn't a keyboard. You probably had your desktop keyboard plugged in and available for the simulator.

    Note that there is no direct way to prevent the virtual keyboard when touching the text control so there is no correct way to "give them an option". The keyboard relies on accessibility state which your app should set appropriately.

    From a usability sense, if I touch the screen I expect the soft keyboard. It is easy to dismiss if I want to switch to the physical. If the keyboard doesn't come up and I have to shift around so I can use the physical keyboard I get very annoyed at the app.

    --Rob

    • Marked as answer by Raptor K Thursday, June 21, 2012 12:24 AM
    Wednesday, June 20, 2012 11:57 PM
    Owner

All replies

  • You should set the appropriate UIA properties and events regardless of whether there is a physical keyboard or not. The soft-keyboard will show only if the user tried to activate it by touching your text control.

    That said, you can check for a keyboard with Windows.Devices.Input.KeyboardCapabilities.KeyboardPresent.

    --Rob

    • Marked as answer by Raptor K Tuesday, June 19, 2012 2:25 AM
    Tuesday, June 19, 2012 2:08 AM
    Owner
  • Thanks.

    I think people may not want to see the virtual keyboard while touching the text control if real keyboard presents. At least we should give them an option.


    C++ DX11

    Tuesday, June 19, 2012 2:29 AM
  • The value of Windows.Devices.Input.KeyboardCapabilities.KeyboardPresent is "1" on simulator.

    Will it be 0 on real pad without keyboard? Or can I customize the simulator to test that situation?

    • Edited by Raptor K Tuesday, June 19, 2012 2:41 AM
    Tuesday, June 19, 2012 2:39 AM
  • KeyboardPresent will return false if there isn't a keyboard. You probably had your desktop keyboard plugged in and available for the simulator.

    Note that there is no direct way to prevent the virtual keyboard when touching the text control so there is no correct way to "give them an option". The keyboard relies on accessibility state which your app should set appropriately.

    From a usability sense, if I touch the screen I expect the soft keyboard. It is easy to dismiss if I want to switch to the physical. If the keyboard doesn't come up and I have to shift around so I can use the physical keyboard I get very annoyed at the app.

    --Rob

    • Marked as answer by Raptor K Thursday, June 21, 2012 12:24 AM
    Wednesday, June 20, 2012 11:57 PM
    Owner