关于keyup keydown,该怎么处理

关于keyup keydown
本帖最后由 bcrun 于 2013-02-27 20:25:46 编辑
Const shift_key = 1
Const ctrl_key = 2
Const alt_key = 4
Const a_key = &H65
Const c_key = &H67  
Const v_key = &H86
Private Sub Command1_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = &H70 Then Print "按下F1" 
End Sub

Private Sub Command1_KeyUp(KeyCode As Integer, Shift As Integer)
If KeyCode = &H70 Then Print "松开F1"
End Sub

Private Sub Command2_Keydown(KeyCode As Integer, Shift As Integer)
If KeyCode = a_key And Shift = shift_key Then
  Print "A"
ElseIf KeyCode = a_key And Shift = 0 Then
  Print "a"
ElseIf KeyCode = c_key And Shift = ctrl_key Then
  Print "复制"
ElseIf KeyCode = v_key And Shift = ctrl_key Then
  Print "粘贴"
End If
End Sub

这个地方command2为什么按ctrl+c 或者V的时候无输出
keycode返回值 十六进制十进制

------解决方案--------------------
因为你的KeyCode不对呀
Const a_key = 65
Const c_key = 67  
Const v_key = 86
是十进制的,不知道哪个你可以print keycode
------解决方案--------------------
有现成的常量:
vbKeyA
vbKeyC
vbKeyV
------解决方案--------------------
还有 Shift 相关也有现成的常量:
vbShiftMask
vbCtrlMask 
vbAltMask