Problems with USB keyboard (keydown and inkey)


Author Message
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 11461
Posted: 04:03pm 02 Oct 2025      

keydown clears the input buffer so you are probably waiting for a repeat. It is not intended that you use keydown with input$. Keydown is intended to give an instantaneous view of anything that is pressed at the instant it is called - the main purpose is for things like game input. MM.USB will likewise give the last key pressed.

If I understand what you are trying to do, you probably don't need MM.USB at all.
Keydown[1] gives you the last key pressed as an ascii character and keydown[7] tells you if any modifier keys are pressed. Together they should allow you program to work out any accented character. Just don't use input$ at all.

You will have to poll keydown on a regular basis and deal with checking for a change to indicate keyup and implement autorepeat if you need it in your Basic program

Just run a tight loop outputting keydown[1] and keydown[7] so you can see how it works
Edited 2025-10-03 02:21 by matherp