C#: How do you display the modifier key name + non-modifier key name in this keydown event?

前端 未结 4 1111
攒了一身酷
攒了一身酷 2021-01-21 22:01

I am using this code to detect whether modifier keys are being held down in the KeyDown event of a text box.

    private void txtShortcut_KeyDown(object sender,          


        
4条回答
  •  难免孤独
    2021-01-21 22:18

    use the ?: Operator

    txtShortcut.Text = (e.Shift? "Shift ": "") + (e.Control? "Control ": "") + (e.Alt? "Alt ": "")  + e.KeyCode.ToString());
    

提交回复
热议问题