通过键盘访问复选框 [英] Checkbox access by keyboard
本文介绍了通过键盘访问复选框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在创建一个登录页面,并希望通过使用键盘让用户灵活地控制焦点。我正在使用AccessKey,但它似乎无法正常工作。任何帮助将不胜感激。
以下是我的电子邮件HTML字段。
I am creating a login page and want to give user the flexibility to control the focus by using keyboard. I am using AccessKey but it seems not working. Any help will be appreciated.
Below is my HTML for Email field only.
<table>
<tr>
<td>
<div class="loginLabel">
<span class="emailPasswordText">Email</span>
</div>
<asp:TextBox ID="txtUserName" runat="server"
TabIndex="1" CssClass="inputCredential" MaxLength="60"
AccessKey="E">
</asp:TextBox>
</td>
</tr>
</table>
<pre lang="text">
我尝试在Mozilla中使用Alt + E和Ctrl + E Firefox。
I tried by using Alt+E and Ctrl+E in Mozilla Firefox.
推荐答案
您可以检查这些来控制键盘上的事件:
http://msdn.microsoft.com/en-us/library/ms171538.aspx [ ^ ]
http://msdn.microsoft.com/en-us/library/system.windows.forms.control.keypress.aspx [ ^ ]
正如您在问题标题中提到的复选框,是否要从键盘中选择并取消选择?如果是,那么您可以使用:
You can check these to control events from keyboard:
http://msdn.microsoft.com/en-us/library/ms171538.aspx[^]
http://msdn.microsoft.com/en-us/library/system.windows.forms.control.keypress.aspx[^]
As you mentioned checkbox in problem title,do you want to select and deselect it from keyboard?If that,then you can use:
private bool YesKey = false
private void Form1_KeyPress(object sender, KeyPressEventArgs e)
{
if (YesKey)
{
chkbox1.Checked = true;
}
else
{
//uncheck it
}
}
private void Form1_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Y)
{
YesKey = true;
}
}
这篇关于通过键盘访问复选框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文