Difference between Keys.Shift and Keys.ShiftKey

2019-01-25 02:35发布

In my application i detect when a key is pressed and see if the modifier is the shift key but the Keys enumerator has Shift and ShiftKey.

It seems the event is always sending Keys.Shift, but is there a case where the Keys.ShiftKey will be used?

(and the same question applies to Keys.Control and Keys.ControlKey)

Thanks for any input.

2条回答
相关推荐>>
2楼-- · 2019-01-25 03:06

Keys.ShiftKey refers to the actual shift key while Keys.Shift refers to the shift modification itself. Keys.ShiftKey can be used like the other key codes to check for presses, but you cannot check to see if the Keys.Shift was pressed because it represents a state rather than an object. I hope this makes sense.

See here:

http://msdn.microsoft.com/en-us/library/system.windows.forms.keys.aspx

查看更多
时光不老,我们不散
3楼-- · 2019-01-25 03:24

Keys.Shift is a modifier key (used for key combinations) while Keys.ShiftKey is a regular key code just like most others in the Keys enumeration.

查看更多
登录 后发表回答