Note that there are some explanatory texts on larger screens.

plurals
  1. POIs there any C# implementation or way to have a textbox that takes a key sequence as input?
    primarykey
    data
    text
    <p>I have an implementation which hooks into the keydown event, which suppresses the keypress event and does some magic. Now I want to show something more friendly than "ControlKey" etc, so there's a switch you can see in the code below. Except I've realised things like the number keys along the top end up as <code>D1</code>, <code>D2</code>, etc., and then there's things like <code>Add</code> showing up for the numpad +. In addition, Print Screen doesn't seem to be recognised.</p> <p>Is there something I'm missing?</p> <p>This is a hard question for me to describe fluently, but hopefully you get what I mean. If not I guess I'll be replying to comments and improving this as I go.</p> <pre><code>private int numKeys = 0; private List&lt;int&gt; shortcutKeys = new List&lt;int&gt;(); private void textBoxRegionKeys_Click(object sender, EventArgs e) { textBoxRegionKeys.SelectAll(); } private void textBoxRegionKeys_KeyDown(object sender, KeyEventArgs e) { // There are certain keys we want to ignore... if (e.KeyCode != Keys.Delete &amp;&amp; e.KeyCode != Keys.Back) { // We can handle this ourselves, thanks e.SuppressKeyPress = true; // Shortern what we show string ret = e.KeyCode.ToString(); switch (ret) { case "ControlKey": ret = "Ctrl"; break; case "ShiftKey": ret = "Shift"; break; case "Menu": ret = "Alt"; break; } // If we haven't selected anything, we should be appending if (textBoxRegionKeys.SelectionLength == 0) { if (numKeys &gt; 0) { // Does our key already exist in the list? if (shortcutKeys.Exists(x =&gt; x == e.KeyValue)) { return; } textBoxRegionKeys.Text += " + "; } textBoxRegionKeys.Text += ret; shortcutKeys.Add(e.KeyValue); numKeys++; } else { textBoxRegionKeys.Text = ret; shortcutKeys.Clear(); shortcutKeys.Add(e.KeyValue); numKeys = 1; } } } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload