Focus and Keyboard Control

May 15, 2012 at 11:25 AM

I'm using SharpGL to draw a surface in a WPF application. I want to emulate the keyboard and mouse control of another application and it uses Shift + Right Click drag to zoom in and out. In the end I use the InputManager to get keyboard states whenever mouse events occurred,

        private bool IsZoomModifierActive(MouseEventArgs e) {
            return (InputManager.Current.PrimaryKeyboardDevice.IsKeyDown(Key.LeftShift) || InputManager.Current.PrimaryKeyboardDevice.IsKeyDown(Key.RightShift)) &&
                    e.RightButton == MouseButtonState.Pressed;

But originally I was trying KeyDown events. It seems that the control cannot get focus and thus cannot get the key events. But it will react to mouse events. So,

- Why is the control not focusable or am I doing something silly.

- How would you react to keyboard events on the control (register at the application level? This is not ideal as this is one module in a composite application)

- Is the method above a good solution for this situation?