System.Windows.Forms.DragEventArgs.KeyState Property

Gets the current state of the SHIFT, CTRL, and ALT keys, as well as the state of the mouse buttons.

Syntax

public int KeyState { get; }

Value

Documentation for this section has not yet been entered.

Remarks

You can make the effect of a drag-and-drop operation to depend on the state of a particular key. For example, you may decide to copy or move data depending on whether the CTRL or SHIFT keys are pressed during the drag-and-drop operation.

The bits that are set in the DragEventArgs.KeyState property identify the keys or mouse buttons that were pressed during the operation. For example, if the left mouse button is pressed, the first bit in the DragEventArgs.KeyState property is set. You can use the bitwise AND operator to test for a given key state.

The following table lists the values that are used for a specified event.

1 (bit 0)

The left mouse button.

2 (bit 1)

The right mouse button.

4 (bit 2)

The SHIFT key.

8 (bit 3)

The CTRL key.

16 (bit 4)

The middle mouse button.

32 (bit 5)

The ALT key.

Requirements

Namespace: System.Windows.Forms
Assembly: System.Windows.Forms (in System.Windows.Forms.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0