This project is read-only.

how to detect Ctrl KeyPress

Aug 24, 2009 at 7:26 AM

I need to implement a functionality where mouse-right-click menu when pressed with keyboard Ctrl key, it should display a different option. But I am not able to figure out how to pass Ctrl key pressed status to the container form of the grid.

Any ideas? suggestion?


Aug 24, 2009 at 10:13 AM

I think that if you want to know the Control key status at a specific time outside of a KeyDown event, you'll have to use Windows API/import specific DLLs or add your own Key state management.

You can do it with static vars that you set when Contol (or Shift) key is pressed or released. And to catch the key event, you'll have to add a Controller to your grid cells:

public class KeyEvent : SourceGrid.Cells.Controllers.ControllerBase
    public KeyEvent()

    public override void OnKeyDown(SourceGrid.CellContext sender, KeyEventArgs e)
        base.OnKeyDown(sender, e);

        keyCtrlPressed = e.Control;
        keyShiftPressed = e.Shift;


Aug 24, 2009 at 11:59 AM

I tried the same approach.

It works for me.