Click here to Skip to main content
15,890,717 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
C#
private void timer1_Tick(object sender, EventArgs e){

      if (Form.ModifierKeys == System.Windows.Forms.Keys.Control && Form.ModifierKeys == System.Windows.Forms.Keys.Enter)
         my_translate(textbox1.text);
 
}


I try it but dont work how can I do it?

I am writing a dictionary software; with timer I check determine pressed keys so I translate word.

C#
//The code is working
private void timer1_Tick(object sender, EventArgs e){

            MouseButtons aa = MouseButtons;
            if (aa == MouseButtons.Middle && Form.ModifierKeys == Keys.Control)
                      my_translate(textbox1.text);
}
Posted
Updated 22-Jun-13 1:32am
v2
Comments
Calvijn 21-Jun-13 12:39pm    
Why detecting during a timer ?
More Details Please.

For "usually" detecting and handling of KeyPress Events you could use Solution 1
Member 9522119 22-Jun-13 7:28am    
I write a dictionary software with timer I check determine pressed keys so I translate word

You would have to use the given EventArgument Property to determine which Key was pressed.

like this
C#
private void objectXY_KeyPress(object sender, System.Windows.Forms.KeyPressEventArgs e)
{
    if(e.KeyChar == (char)Keys.Enter && Form.ModifierKeys == Forms.Keys.Control)
    {     }
}

or this (depends on which .NET Version you work)
C#
private void textBox1_KeyPress(object sender, System.Windows.Forms.KeyPressEventArgs e)
{
    if( e.KeyCode == Keys.Enter && e.Modifiers == Keys.Control)
    {     }
}


This one is to handle multiple modifiers.
C#
private void textBox1_KeyPress(object sender, System.Windows.Forms.KeyPressEventArgs e)
{
    if( e.KeyCode == Keys.Enter && e.Modifiers == (Keys.Control || Keys.Shift)
    {     }
}
 
Share this answer
 
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900