set
this.KeyPreview = true;
and use this code
private void Form1_KeyPress(object sender, KeyPressEventArgs e)
{
foreach (Control con in this.Controls)
{
if (con is TextBox)
{
if (con.Focused)
{
con.Text = "s";
}
}
}
}
or use this code:
private void Form1_KeyPress(object sender, KeyPressEventArgs e)
{
Control con = this.ActiveControl;
if (con is TextBox)
{
con.Text = "s";
}
}