Search code examples
winformstextboxkeyboard-shortcuts

Disable all shortcuts in a text box


I am aware of the shortcuts enabled property, however, It does not disable all shortcuts.

For example, zooming with ctrl+mousewheel or writing superscript letters with ctrl+shift+plus.

If you're giving me a solution that disables shortcuts by their name, id, keys, etc., please give me a list of all the shortcuts and their names, ids, keys etc.


Solution

  • Eureka! To handle a key press by myself without letting the form handle it simply:

    void OnRichTextBoxKeyDown(object sender, KeyEventArgs e)
    {
         if(e.Control && e.Shift && e.KeyCode == Keys.Oemplus)
         {
             MessageBox.Show("Why Would I ever Want to Write Superscript Letters?!");
             e.Handled = true;
         }
    }
    

    Now here is a list of all the shortcuts coming with a rich text box, although, I tried some of them out and they didn't work, so you got to check first.