Advertisement Jump to content
Sign in to follow this  
Steven Ford

Keyboard support - Xbox 1 / UWP (Creators Collection)

Recommended Posts

Hi all,

having gotten the game virtually ready for release (development used a Win32 wrapper as easier), I now need to create a UWP version of the app for release on the X1 (Creators Collection). My initial expectation would be to have the UWP version solely available for the Xbox 1 and to get the game released on Steam for the PC. Given that the MS store allows the game to be released on both X1 / PC, I'm thinking that if I can get the UWP version to function on the PC then I might as well do it to widen the possible audience.

I currently allow a user to play with either a game pad or a keyboard and show various settings related to the keyboard input. For the UWP version, I've added a flag which is permanently set to false in the UWP version to say whether to show the keyboard feature. Obviously this approach isn't ideal if I do want to allow the UWP version to run on the PC. So the questions are...

1. How does one detect that the app is running on a device without a keyboard / an X1 (this presumes that they're the same question, but I don't think that that's true for reasons in #3)?
2. If you were an X1 player and you saw the option to view the keyboard settings would this be irritating or would you simply not care?
3. Given that one can plug in a keyboard to an X1 and it appears to work (at least in 'Dev Home'), would you expect to go with the simple option and just allow them?

Assuming that this was to be allowed, is there a message that I can subscribe to to say that the keyboard is now attached or is it a question of simply polling (assuming that I went for the approach of not showing keyboard options unless one was attached).

Any thoughts?



Share this post

Link to post
Share on other sites

Disclaimer: I also made a UWP game, but didn't enable XBox support (no XBox to test on, so it's pretty difficult to verify if any problems arise). So I can't verify the snippet below.

Anyhow, on Stack Overflow this snippet was found:

private void GetKeyboardProperties()
    KeyboardCapabilities keyboardCapabilities = new Windows.Devices.Input.KeyboardCapabilities();
    KeyboardPresent.Text = keyboardCapabilities.KeyboardPresent != 0 ? "Yes" : "No";


Edited by Endurion

Share this post

Link to post
Share on other sites

Thanks squire; looks to be trivial to enable it [support] and removing it seems to cause more hassle than it's worth so might as well leave it in. Doesn't cost me much.

Share this post

Link to post
Share on other sites

Just adding a code snippet of how this [handling of keyboard inputs] was done in case it's useful to anyone else (and me for later reference 🙂 ).

Look at the following Forum Post ( @Endurion 's one) to see a subset of the possible inputs. To do these in C++/winrt; the following syntax can be used

// SetWindow from templates
// Window = CoreWindow

		// Tokens which can be used to remove the event listeners later
		winrt::event_token _keyDownToken, _keyUpToken;

		_keyDownToken = window.KeyDown([this](auto&& /*sender*/, auto&& args) {
			int keyCode = (int)args.VirtualKey();

		_keyUpToken = window.KeyUp([this](auto&& /*sender*/, auto&& args) {
			int keyCode = (int)args.VirtualKey();


Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!