Preliminary Idea: textbox. readonly = true; but in this way, even card swiping input will be disabled.
The second idea is to determine whether the keyboard is input or the user swiping the card, but how to determine whether the keyboard input should trigger a keydown event or the like. The result is the same as the trigger.
The third idea-roundabout: because the card number is a card number of a specific length, it can be entered to a specific length in a short period of time, and the user input must be at least 4 S. It can be determined by this time to determine whether to manually input or swipe the card.
I used a timer control to debug its attribute internal to 200 ms
CodeAs follows:
Code
Private Void Timereffectick ( Object Sender, eventargs E)
{
If (Textboxx1.text. Length ! = Textboxx1.maxlength)
{ // Check whether the text box content length is equal to the maximum length at a specified time
Timer1.enabled = False ;
Textboxx1.text = "" ;
}
}
Private Void Textboxx1_previewkeydown ( Object Sender, previewkeydowneventargs E)
{ // When entering content in the text box, this event in the text box is triggered first.
Timer1.enabled = True ;
}