简体中文 繁體中文 English 日本語 Deutsch 한국 사람 بالعربية TÜRKÇE português คนไทย

导读切换到宽版
Online Supporting

 找回密码
 立即注册
搜索
热搜: 活动 交友 discuz
查看: 861|回复: 1

Long press button

[复制链接]

1

主题

2

回帖

17

积分

新手上路

积分
17
发表于 2023-12-28 01:55:10 | 显示全部楼层 |阅读模式
Is there a way to use the long press button? Some games need to you not only to hit a key, but to long press it. I tried using press-down + pause + press-up but seems not work. I know that long press feature can be emulated with windows programming, like:

  1. //consider keys held less than one second a short keypress event
  2. const double longThresholdMs = 1000.0;
  3. Dictionary<Keys, DateTime> keyDownTimes = new Dictionary<Keys, DateTime>();

  4. private void Form1_KeyDown(object sender, KeyEventArgs e)
  5. {
  6.     if (!keyDownTimes.ContainsKey(e.KeyCode))
  7.     {
  8.         keyDownTimes[e.KeyCode] = DateTime.Now;
  9.     }
  10. }

  11. private void Form1_KeyUp(object sender, KeyEventArgs e)
  12. {
  13.     if (keyDownTimes.ContainsKey(e.KeyCode))
  14.     {
  15.         if (DateTime.Now.Subtract(keyDownTimes[e.KeyCode]).TotalMilliseconds > longThresholdMs)
  16.         {
  17.             Console.Out.WriteLine(e.KeyCode + " long press");
  18.         }
  19.         else
  20.         {
  21.             Console.Out.WriteLine(e.KeyCode + " short press");
  22.         }

  23.         keyDownTimes.Remove(e.KeyCode);
  24.     }
  25. }
复制代码



If not already there, can you implement that feature?


144

主题

926

回帖

3017

积分

版主

积分
3017
发表于 2023-12-28 11:32:15 | 显示全部楼层
In the current version, we have not yet defined the code for the long press function. In future versions, we will add the long press function
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

Archiver|手机版|小黑屋|Stream Dock 论坛 ( 粤ICP备16086630号 )

GMT+8, 2024-11-24 10:16 , Processed in 0.157579 second(s), 22 queries .

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表