W343-4 designates a bug that affects the Microsoft Windows version of NetHack 3.4.3. It occurs when the keyboard handler nhraykey.dll is loaded and causes minor problems with the keyboard when performing certain acts, such as locking a door.
Nature of the bug
Bug W343-4 affects all users of NetHack on Windows who use the text mode user interface and the keyboard handler nhraykey.dll.
After performing any act that takes multiple turns and can be interrupted, such as locking a door, the game seems to stop responding. It is necessary to press a key to get it to continue.
This bug is an annoyance rather than a showstopper, but has perhaps slowed the acceptance of nhraykey.dll, despite its improved handling of non-USA (and especially non-English) keyboards.
Cause of the bug
Nhraykey.dll seeks to read both keyboard and mouse input, while translating the keystrokes according to the user's configured localization settings. The Win32 API does not make this task easy: ReadConsole translates the keystrokes, but ignores the mouse, while ReadConsoleInput reads the mouse, but does not translate the keystrokes. Nhraykey.dll solves this problem by calling PeekConsoleInput first, and then calling ReadConsole to retrieve any keystrokes and ReadConsoleInput to clear out anything else.
The complication is that there can be a keystroke, but the call to ReadConsole may still block, keeping the mouse from responding, because the key was a dead key. Nhraykey.dll prevents the blocking by pushing a bogus key event on the queue before calling ReadConsole; if nothing else, the ReadConsole call will return the bogus key.
The bogus key is supposed to be ignored when it is read. The bug is that one particular function, NHkbhit(), doesn't do this. It returns a true status, indicating that a real key is available, and allmain.c then calls Getchar() to retrieve this nonexistent key. The user must eventually provide a real key for Getchar() to return.
The fix is to add a check for the bogus key in NHkbhit(). If found, the bogus key is discarded and the queue is queried again.