'How do I clear the keystroke buffer from int 16h

I've tried Flush Keyboard Buffer x86 assembly using int 16h 's solution, and it didn't work. I did everything I could to stop the buffer from happening and nothing seems to work.

I am currently making a game in assembly, and when I press for example "w" for too long, the character will continue moving for a little more then half a second after I stopped pressing "w".

this is my mainloop that detects when a key is pressed, but for some reason remember previous keys:

mainloop:
    mov ah, 1h
    int 16h
    jz after_press
    mov ah, 0h
    int 16h
    cmp ah, 11h                 ; 11h == scancode for W
    jne mlr1
    call link_up
    mlr1:
        cmp ah, 1Eh             ; 1Eh == scancode for A
        jne mlr2
        call link_left
    mlr2:
        cmp ah, 1Fh             ; 1Fh == scancode for S
        jne mlr3
        call link_down
    mlr3:
        cmp ah, 20h             ; 20h == scancode for D
        jne after_press
        call link_right
    after_press:
        mov ax, 5h
        mov bx, 0h
        int 33h
        cmp ax, 1h
        jne asrd
        call use_sword
    asrd:
    call octorok_ai
    mov bx, 1h ; delay time
    call delay
    jmp mainloop

If someone can please tell me how do I clear the buffer, I will be gratefull



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source