我建立一个应用程序UWP,我希望用我的应用程序禁用键盘交互。这意味着我的应用程序不应该以任何方式响应时,键盘上的任意键被按下。
这是可以实现的?我可以有选择地禁止与像Tab键等一些关键的相互作用
是的,你可以使用KeyboardDeliveryInterceptor类此。事情与此需要注意的几个:
<Capabilities>
<Capability Name="internetClient" />
<rescap:Capability xmlns:rescap="http://schemas.microsoft.com/appx/manifest/foundation/windows10/restrictedcapabilities" Name="inputForegroundObservation"/>
</Capabilities>
KeyboardDeliveryInterceptor interceptor = KeyboardDeliveryInterceptor.GetForCurrentView();
interceptor.IsInterceptionEnabledWhenInForeground = true;
interceptor.KeyUp += delegate(KeyboardDeliveryInterceptor sender, KeyEventArgs args)
{
if (args.VirtualKey == Windows.System.VirtualKey.Tab)
{
// perform desired tab key action
}
};