0

I am using a webviewer that loads the website content in a picturebox which I have set up as a keypress listener. My KeyDown function works very well when the application starts. But after one mouseclick on the website (content) the KeyDown function is not working anymore. Is there a way to always listen to keypresses without looking to any objects?

Here is my code that handles the keypress:

//Inside the Form1_load method:

        this.KeyPreview = true;
        this.KeyDown += new KeyEventHandler(picturebox1_KeyDown);

        //FormBorderStyle = FormBorderStyle.None;
        //this.WindowState = FormWindowState.Maximized;
    }

    private void picturebox1_KeyDown(object sender, KeyEventArgs e)
    {

        if (e.KeyCode == Keys.F11 && fs == "none")
        {
            FormBorderStyle = FormBorderStyle.None;
            fs = "active";
        }
        else
        {
            FormBorderStyle = FormBorderStyle.Sizable;
            fs = "none";
        }
    }

I already tried to duplicate this method for Form1, webView1, contextMenuStrip1 etc. for all my objects, but none of these works.

I want my application to go Fullscreen when F11 is pressed.

Salihan Pamuk
  • 175
  • 1
  • 2
  • 13

0 Answers0