C# 将 Keycode 传输到 Keychar

发布于 2025-01-14 10:00:53 字数 722 浏览 7 评论 0原文

我知道这个问题是由使用“Keydown-Keycode”而不是“Keypress-Keychar”引起的,但是如何让我的 Keydown 使用 Keychar 呢?有什么想法。 我使用全局键盘钩子,该钩子似乎只使用 KeyUp 和 KeyDown。如果你知道如何获得一个全局钩子来使用 KeyPress,那就太棒了

    private string b = string.Empty;
 
    public void gkhr_KeyDown(object sender, KeyEventArgs e)
    {




       
        s += (char)e.KeyCode;
        b = s; // i made b = s because otherwise it would add two values together
        b = b.ToLower(); // Was able to use A-Z in lowercase here
        s = string.Empty; // cheeky little hack
        MessageBox.Show(b);

当我单击键盘“时,”它显示“3/4”。 另一个例子是“F1”打印“q”

链接 [1]: https://i.sstatic.net/LiQ9e.png

I know this issue is caused by using "Keydown-Keycode" and not "Keypress-Keychar" but how would I get my Keydown to use Keychar instead? Any thoughts.
Im using a global keyboard hook and the hook only seems to use KeyUp and KeyDown. If you know how I can get a global hook to use KeyPress that would be awesome

    private string b = string.Empty;
 
    public void gkhr_KeyDown(object sender, KeyEventArgs e)
    {




       
        s += (char)e.KeyCode;
        b = s; // i made b = s because otherwise it would add two values together
        b = b.ToLower(); // Was able to use A-Z in lowercase here
        s = string.Empty; // cheeky little hack
        MessageBox.Show(b);

When I click on keyboard "," it displays "3/4".
Another example being "F1" prints "q"

Link
[1]: https://i.sstatic.net/LiQ9e.png

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文