|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Simple keyboard problem
I made a simple 2D game engine where a picture or label would move around the screen by keyboard commands encoded into a timer. It was a simple and effective method. I lost the damn code and only have the exe. Basically the code inside the timer was something like this.
Quote:
I know there are better ways of doing it, but for this I ask you to refresh my memory on what the code was! Thanks! |
|
#2
|
|||
|
|||
|
Private Sub txtSend_KeyDown(KeyCode As Integer, Shift As Integer)
If (KeyCode = vbKeyReturn) Or KeyCode = vbKeyReturn Then ............... your codes end if end sub |
|
#3
|
|||
|
|||
|
Thanks.
![]() |
|
#4
|
|||
|
|||
|
is that correct??
|
|
#5
|
|||
|
|||
|
Re: Simple keyboard problem
well it looks nice but i dont get that simple key thing running. could u give me a full but simple example of this?
|
|
#6
|
|||
|
|||
|
key code constants
Key Codes
Constant Value Description vbKeyLButton 1 Left mouse button vbKeyRButton 2 Right mouse button vbKeyCancel 3 CANCEL key vbKeyMButton 4 Middle mouse button vbKeyBack 8 BACKSPACE key vbKeyTab 9 TAB key vbKeyClear 12 CLEAR key vbKeyReturn 13 ENTER key vbKeyShift 16 SHIFT key vbKeyControl 17 CTRL key vbKeyMenu 18 MENU key vbKeyPause 19 PAUSE key vbKeyCapital 20 CAPS LOCK key vbKeyEscape 27 ESC key vbKeySpace 32 SPACEBAR key vbKeyPageUp 33 PAGE UP key vbKeyPageDown 34 PAGE DOWN key vbKeyEnd 35 END key vbKeyHome 36 HOME key vbKeyLeft 37 LEFT ARROW key vbKeyUp 38 UP ARROW key vbKeyRight 39 RIGHT ARROW key vbKeyDown 40 DOWN ARROW key vbKeySelect 41 SELECT key vbKeyPrint 42 PRINT SCREEN key vbKeyExecute 43 EXECUTE key vbKeySnapshot 44 SNAPSHOT key vbKeyInsert 45 INS key vbKeyDelete 46 DEL key vbKeyHelp 47 HELP key vbKeyNumlock 144 NUM LOCK key KeyA Through KeyZ Are the Same as Their ASCII Equivalents: 'A' Through 'Z' Constant Value Description vbKeyA 65 A key vbKeyB 66 B key vbKeyC 67 C key vbKeyD 68 D key vbKeyE 69 E key vbKeyF 70 F key vbKeyG 71 G key vbKeyH 72 H key vbKeyI 73 I key vbKeyJ 74 J key vbKeyK 75 K key vbKeyL 76 L key vbKeyM 77 M key vbKeyN 78 N key vbKeyO 79 O key vbKeyP 80 P key vbKeyQ 81 Q key vbKeyR 82 R key vbKeyS 83 S key vbKeyT 84 T key vbKeyU 85 U key vbKeyV 86 V key vbKeyW 87 W key vbKeyX 88 X key vbKeyY 89 Y key vbKeyZ 90 Z key Key0 Through Key9 Are the Same as Their ASCII Equivalents: '0' Through '9 Constant Value Description vbKey0 48 0 key vbKey1 49 1 key vbKey2 50 2 key vbKey3 51 3 key vbKey4 52 4 key vbKey5 53 5 key vbKey6 54 6 key vbKey7 55 7 key vbKey8 56 8 key vbKey9 57 9 key Keys on the Numeric Keypad Constant Value Description vbKeyNumpad0 96 0 key vbKeyNumpad1 97 1 key vbKeyNumpad2 98 2 key vbKeyNumpad3 99 3 key vbKeyNumpad4 100 4 key vbKeyNumpad5 101 5 key vbKeyNumpad6 102 6 key vbKeyNumpad7 103 7 key vbKeyNumpad8 104 8 key vbKeyNumpad9 105 9 key vbKeyMultiply 106 MULTIPLICATION SIGN (*) key vbKeyAdd 107 PLUS SIGN (+) key vbKeySeparator 108 ENTER (keypad) key vbKeySubtract 109 MINUS SIGN (-) key vbKeyDecimal 110 DECIMAL POINT(.) key vbKeyDivide 111 DIVISION SIGN (/) key Function Keys Constant Value Description vbKeyF1 112 F1 key vbKeyF2 113 F2 key vbKeyF3 114 F3 key vbKeyF4 115 F4 key vbKeyF5 116 F5 key vbKeyF6 117 F6 key vbKeyF7 118 F7 key vbKeyF8 119 F8 key vbKeyF9 120 F9 key vbKeyF10 121 F10 key vbKeyF11 122 F11 key vbKeyF12 123 F12 key vbKeyF13 124 F13 key vbKeyF14 125 F14 key vbKeyF15 126 F15 key vbKeyF16 127 F16 key ------------------------------- In vb, all key press is assigned a hex value.. in a textbox or command button for instance... in the _keypress, _keydown, or _keyup events, this is triggered when a keyboard button is pressed.. lets say Private Sub txtSend_KeyDown(KeyCode As Integer, Shift As Integer) msgbox keycode end sub this will trigger the msgbox when a key is pressed.. and displays the integer value assigned.. get it yet?? |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > Visual Basic Programming > Simple keyboard problem |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|