如何将值转换为KeyCode? [英] How to convert a value to KeyCode ?

查看:82
本文介绍了如何将值转换为KeyCode?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有非英语键盘,所以我的键盘不是+ 1,而是+.当我按下一个键时,我从KeyChar.ToString()得到一个字符串,非英语键盘也为"+",而英语键盘为"1".
如何将该字符串转换为KeyCode Keys.D1 ??
在参数为其中一个条件的情况下,我也总是获得相同的结果,即Keys格式的Keys.D1 ??

例如

I have non-english keyboard, also so instead of 1 of my keyboard i have +. When i press a key i get a string from KeyChar.ToString(), also "+" with non-english keyboard and "1" with english-keyboard.
How can i convert this string to KeyCode Keys.D1 ??
With the condition when the parameter will be one of them, i always get the same result also Keys.D1 in format Keys ??

For example

private Keys ConvertToKeys(string s)
        {
             // code
        }
...

ConvertToKeys("+") // result Keys.D1
ConvertToKeys("1") // result Keys.D1



感谢您的帮助!



Thanx for your help !

推荐答案

使用硬编码

使用if代替条件并返回wt,就像你一样
use hard coding

use if else for conditions and return wt so ever u like


这篇关于如何将值转换为KeyCode?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆