I also was clearing the keyboard buffer in my own entry, there were two methods. I just found something that if I call once per frame after the input read, it mostly works fine even if it might not be the complete solution.
My solution was some interupt call. mov ax,0c00h and then int 21h
However I have some other I didn't use that looks similar to the qbasic solution like here https://www.tek-tips.com/threads/how-do-you-clear-the-input-buffer.77806/
Maybe this one is the easiest to try DEF SEG = &H40: POKE &H1C, PEEK(&H1A): DEF SEG like maybe call it somewhere once in the frame loop after the input checks.
There are also more proper solutions but need more work. In my case I also should have read the input in a continuous loop till the buffer empties. But I just read once and then clear the buffer. Didn't notice issues with keyboard clashing regardless.
Did you btw have the problem yourself or do you run it in Dosbox and you didn't notice the issue?