您的位置:首页 > 移动开发 > Unity3D

unity 键盘检测代码编码总结

2016-03-18 18:40 441 查看
常用按键的按键名与KeyCode编码

       键盘按键                           Name                                                   KeyCode

     字母键:A,B,C……..Z           a,b,c…….z                              A,B,C……..Z  (KeyCode.A)

 

     数字键0-9                            0-9                                             Alpha0-----Alpha9

 

     功能键F1—F12                  f1---f12                                       F1—F12

 

     退格键                                backspace                                  Backspace

 

     回车键                                return                                            Return

 

     空格键                                space                                          Space

 

     退出键                                esc                                               Esc

 

     Tab键                                  tab                                               Tab

 

 

     上下左右方向键            up,down ,left, right                         UpArrow,DownArrow,LeftArrow

 

     左右shift键                     leftshift   ,right shift                         LeftShift, RightShift

 

    左右Alt键                        left alt, right alt                                 LeftAlt  , RightAlt

 

     左右Ctrl键                      leftctrl  , rightctrl                               LeftCtrl,RightCtrl

 

 

    使用案例:检测空格键

       if(Input.GetKeyDown("space"))    {Instantiate(projectile_bl,transform.position,transform.rotation);}

 

      if(Input.GetKeyDown(KeyCode.Space))
  {Instantiate(projectile_bl,transform.position,transform.rotation);}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  uniyt 按键编码