如何让方向键充当其他键的作用?
在Silverlight项目中,如何使向左箭头的行为类似于.(点),当用户在文本框中按向左箭头时,它将键入 。以及以同样的方式如何使右箭头像 - (破折号)一样
,我想使用 CTRL 键在两种模式之间切换: 。和破折号,常规箭头行为,意味着当用户按下 Control 时,拖曳箭头将充当 。和破折号。当用户再次按下控件时,两个箭头将像平常的箭头一样起作用。
In Silverlight project, how to make the left arrow act like . (dot), when a user press the left arrow in a textbox it will type . and also in the same way how to make the right arrow act like - ( dash)
And I want to use the CTRL key to switch between 2 modes: . and dash, regular arrows behavior, mean when a user press Control the tow arrows will act as . and dash. And when a user press agian the control the 2 arrows will act as usual arrows.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果是 win 表单或 WPF,您只需捕获按键事件并更改其行为,然后将其设置为“已处理”(在 (PreviewKeyDown) 之前和之后有一堆事件,您可以使用它们来完全控制每个事件上发生的情况 。
您还可以使用 API 检查是否按下了 CTRL 键
在 WPF 中使用 KeyboardDevice 属性,检查:
添加:
同时 - 检查一下SO问题
和这也是:SO问题2
If it's win forms or WPF you just catch the event of the keypressed and change it's behavior and than set it as "Handled" (there is a bunch of events before and after (PreviewKeyDown) that you can use to fully control what happens on every key pressing.
You can check if CTRL key is pressed as well using API.
using KeyboardDevice Property in WPF, checking:
Addition:
Meanwhile - check this out SO question
and This one as well: SO Question2