C# or .NET Flushing Keyboard Buffer

后端 未结 7 1360
太阳男子
太阳男子 2021-01-12 08:34

How do I flush the keyboard buffer in C# using Windows Forms?

I have a barcode scanner which acts like a keyboard. If a really long barcode is scanned and the cancel

7条回答
  •  夕颜
    夕颜 (楼主)
    2021-01-12 09:20

    Set KeyPreview on the Form to true, then catch the KeyPress event and set e.Handled to true if cancel was clicked.

    EDIT: Catch the Form's KeyPress event

提交回复
热议问题