SHOW:
|
|
- or go back to the newest paste.
| 1 | - | CHAR getch() |
| 1 | + | WCHAR getch() |
| 2 | {
| |
| 3 | HANDLE hstdin = GetStdHandle (STD_INPUT_HANDLE); | |
| 4 | INPUT_RECORD InputRecord; | |
| 5 | DWORD EventsRead; | |
| 6 | - | CHAR Key; |
| 6 | + | WCHAR Key; |
| 7 | ||
| 8 | while(ReadConsoleInputA (hstdin, &InputRecord, 1, &EventsRead) ) /* czeka na input event */ | |
| 9 | {
| |
| 10 | if(InputRecord.EventType == KEY_EVENT | |
| 11 | && InputRecord.Event.KeyEvent.wVirtualKeyCode != VK_SHIFT | |
| 12 | && InputRecord.Event.KeyEvent.wVirtualKeyCode != VK_MENU /* ALT_KEY */ | |
| 13 | && InputRecord.Event.KeyEvent.wVirtualKeyCode != VK_CONTROL | |
| 14 | && InputRecord.Event.KeyEvent.wVirtualKeyCode != VK_CAPITAL /* CAPS LOCK */ | |
| 15 | ) | |
| 16 | {
| |
| 17 | - | Key = InputRecord.Event.KeyEvent.uChar.AsciiChar; |
| 17 | + | Key = InputRecord.Event.KeyEvent.uChar.UnicodeChar; |
| 18 | ReadConsoleInputA(hstdin, &InputRecord, 1, &EventsRead) //Bez tego by wypisywało tak szybko, że jedno naciśnięcie klawisza, wypisywało by 2 razy to samo :) | |
| 19 | ||
| 20 | return Key; | |
| 21 | } | |
| 22 | } | |
| 23 | return EOF; | |
| 24 | } |