Difference between the KeyDown Event, KeyPress Event and KeyUp Event in Visual Studio

前端 未结 5 560
小蘑菇
小蘑菇 2020-11-29 03:36

Can anyone tell me the difference between the KeyDown event, the KeyPress event and the KeyUp event? I checked the msdn site and it do

5条回答
  •  误落风尘
    2020-11-29 03:44

    KeyDown then KeyPress then KeyUp is the order I find.

    Usually you want to hook KeyDown when it is for an application where a user holds down a key for multi-mode input with control key mode modification, like in a shift-click operation. KeyPress is for simple key entry type logic -- just getting the key strokes. KeyUp is hooked to put in logic that executes after something else processes KeyPress, like to modify the contents of a text edit box after it's main KeyPress logic has taken effect. Frankly, I don't use KeyUp all that much, but sometimes it is the only way to get a message after something else has processed KeyPress and you need to check on / fixup what happened.

提交回复
热议问题