Disable ASCII Control characters shortcuts?
-
These are a list of shortcuts for ASCII control characters I’ve found so far. I wish to keep all of them from appearing while I’m typing. I can accidentally hit these shortcuts when I’m trying to use other shortcuts like Ctrl + Z or Ctrl + V, for example. I’m using Windows and I could find no way to remove these from the shortcut mapper.
~ Shift + Esc = (ESC)
~ Ctrl + E = (ENQ)
~ Ctrl + R = (DC2)
~ Ctrl + Pause\Break = (ETX)
~ Ctrl + Shift + Y = (EM)
~ Ctrl + Shift + W = (ETB)
~ Ctrl + Shift + O = (SI)
~ Ctrl + Shift + A = (SOH)
~ Ctrl + Shift + D = (EOT)
~ Ctrl + Shift + G = (BEL)
~ Ctrl + Shift + H = (BS)
~ Ctrl + Shift + Z = (SUB)
~ Ctrl + Shift + X = (CAN)
~ Ctrl + Shift + C = (ETX)
~ Ctrl + Shift + v = (SYN)
~ Ctrl + Shift + B = (STX)
~ Ctrl + Shift + N = (SO)
~ Ctrl + Shift + 6 + (RS)
~ Ctrl + Shift + -(Dash) = (US) -
I find something along these lines an excellent feature suggestion!
-
Couldn’t agree more. Don’t know how many times I’ve done this. Especially
Ctrl+Shift+Z
. -
Well, kind of a hack, you could simply assign shortcuts to no action macro, couldn’t you?
Something like<Macro name="RemoveControlCharSUB" Ctrl="yes" Alt="no" Shift="yes" Key="90"> <Action type="" message="" wParam="" lParam="" sParam="" /> </Macro>
Cheers
Claudia -
I’m going to shamelessly promote my new plugin. If you install the plugin and put the following code in the startup script it will get rid of most of these shortcuts.
editor:AssignCmdKey(string.byte('E'), SCMOD_CTRL, SCI_NULL) editor:AssignCmdKey(string.byte('R'), SCMOD_CTRL, SCI_NULL) editor:AssignCmdKey(string.byte('E'), SCMOD_CTRL + SCMOD_SHIFT, SCI_NULL) editor:AssignCmdKey(string.byte('Y'), SCMOD_CTRL + SCMOD_SHIFT, SCI_NULL) editor:AssignCmdKey(string.byte('W'), SCMOD_CTRL + SCMOD_SHIFT, SCI_NULL) editor:AssignCmdKey(string.byte('O'), SCMOD_CTRL + SCMOD_SHIFT, SCI_NULL) editor:AssignCmdKey(string.byte('A'), SCMOD_CTRL + SCMOD_SHIFT, SCI_NULL) editor:AssignCmdKey(string.byte('D'), SCMOD_CTRL + SCMOD_SHIFT, SCI_NULL) editor:AssignCmdKey(string.byte('G'), SCMOD_CTRL + SCMOD_SHIFT, SCI_NULL) editor:AssignCmdKey(string.byte('H'), SCMOD_CTRL + SCMOD_SHIFT, SCI_NULL) editor:AssignCmdKey(string.byte('Z'), SCMOD_CTRL + SCMOD_SHIFT, SCI_NULL) editor:AssignCmdKey(string.byte('X'), SCMOD_CTRL + SCMOD_SHIFT, SCI_NULL) editor:AssignCmdKey(string.byte('C'), SCMOD_CTRL + SCMOD_SHIFT, SCI_NULL) editor:AssignCmdKey(string.byte('V'), SCMOD_CTRL + SCMOD_SHIFT, SCI_NULL) editor:AssignCmdKey(string.byte('B'), SCMOD_CTRL + SCMOD_SHIFT, SCI_NULL) editor:AssignCmdKey(string.byte('N'), SCMOD_CTRL + SCMOD_SHIFT, SCI_NULL) editor:AssignCmdKey(string.byte('6'), SCMOD_CTRL + SCMOD_SHIFT, SCI_NULL)
-
@dail there is nothing to shame about, you offer a new plugin and a solution to a problem.
Sounds like a successful day to me ;-)
And you remembered me about a function AssignCmdKey which I have nearly forgotten.So a python script would look like this
editor.assignCmdKey(ord('E')+(2<<16),2172) editor.assignCmdKey(ord('R')+(2<<16),2172) editor.assignCmdKey(ord('Y')+(3<<16),2172) editor.assignCmdKey(ord('W')+(3<<16),2172) editor.assignCmdKey(ord('O')+(3<<16),2172) editor.assignCmdKey(ord('A')+(3<<16),2172) editor.assignCmdKey(ord('D')+(3<<16),2172) editor.assignCmdKey(ord('G')+(3<<16),2172) editor.assignCmdKey(ord('H')+(3<<16),2172) editor.assignCmdKey(ord('Z')+(3<<16),2172) editor.assignCmdKey(ord('X')+(3<<16),2172) editor.assignCmdKey(ord('C')+(3<<16),2172) editor.assignCmdKey(ord('V')+(3<<16),2172) editor.assignCmdKey(ord('B')+(3<<16),2172) editor.assignCmdKey(ord('N')+(3<<16),2172) editor.assignCmdKey(ord('6')+(3<<16),2172) editor.assignCmdKey(189+(3<<16),2172) editor.assignCmdKey(27+(1<<16),2172) editor.assignCmdKey(19+(2<<16),2172) # this seems not to work although 19 should be the key code of break key
Cheers
Claudia -
Yeah I’ve always been a fan of the PythonScript plugin (even stole code from that project :)). However for alot of my uses it was over kill in terms of RAM and initialization time to make it worth it.
-
That’s the beauty of having multiple programming/scripting languages, isn’t it. ;-)
Having lua as npp scripting extension can force me to learn more about it because
it’s also an extension to wireshark afaik.Thank you
Claudia -
ok this should do the trick for CTRL+break
editor.assignCmdKey(3+(KEYMOD.CTRL << 16),2172)
Cheers
Claudia -
After testing again, I saw that SHIFT+ESC still worked, strange.
So figured out, thateditor.assignCmdKey(27+(1<<16),2172)
is wrong and should be
editor.assignCmdKey(7+(1<<16),2172)
instead. Hmm…
So the full list more user friendly
editor.assignCmdKey(ord('E') + (KEYMOD.CTRL << 16),2172) editor.assignCmdKey(ord('R') + (KEYMOD.CTRL << 16),2172) editor.assignCmdKey(ord('Y') + (KEYMOD.SHIFT + KEYMOD.CTRL << 16),2172) editor.assignCmdKey(ord('W') + (KEYMOD.SHIFT + KEYMOD.CTRL << 16),2172) editor.assignCmdKey(ord('O') + (KEYMOD.SHIFT + KEYMOD.CTRL << 16),2172) editor.assignCmdKey(ord('A') + (KEYMOD.SHIFT + KEYMOD.CTRL << 16),2172) editor.assignCmdKey(ord('D') + (KEYMOD.SHIFT + KEYMOD.CTRL << 16),2172) editor.assignCmdKey(ord('G') + (KEYMOD.SHIFT + KEYMOD.CTRL << 16),2172) editor.assignCmdKey(ord('H') + (KEYMOD.SHIFT + KEYMOD.CTRL << 16),2172) editor.assignCmdKey(ord('Z') + (KEYMOD.SHIFT + KEYMOD.CTRL << 16),2172) editor.assignCmdKey(ord('X') + (KEYMOD.SHIFT + KEYMOD.CTRL << 16),2172) editor.assignCmdKey(ord('C') + (KEYMOD.SHIFT + KEYMOD.CTRL << 16),2172) editor.assignCmdKey(ord('V') + (KEYMOD.SHIFT + KEYMOD.CTRL << 16),2172) editor.assignCmdKey(ord('B') + (KEYMOD.SHIFT + KEYMOD.CTRL << 16),2172) editor.assignCmdKey(ord('N') + (KEYMOD.SHIFT + KEYMOD.CTRL << 16),2172) editor.assignCmdKey(ord('6') + (KEYMOD.SHIFT + KEYMOD.CTRL << 16),2172) editor.assignCmdKey(189 + (KEYMOD.SHIFT + KEYMOD.CTRL << 16),2172) editor.assignCmdKey(7 + (KEYMOD.SHIFT << 16),2172) editor.assignCmdKey(3 + (KEYMOD.CTRL << 16),2172)
Cheers
Claudia -
Of course it must be
After testing again, I saw that SHIFT+ESC still didn’t work, strange.
Cheers
Claudia -
Thanks! It worked out brilliantly. This was something that always bothered me about Notepad++. I’m not too big a coder myself, and I’m definitely sure I’ll never use those control characters. Glad I finally got rid of these shortcuts.
I got dail’s plugin working. I couldn’t get Claudia’s python code to work though. I downloaded Python Script 1.0.6 from the plugins manager and upon pressing Show Console, I got an Unknown Exception error message. Pressing the Show Console button again allowed me to popup the console, but I suspect the reason why the console isn’t working because of the unknown exception.
Running
editor:AssignCmdKey(string.byte(‘E’), SCMOD_CTRL, SCI_NULL)
in the console did not change my key assignments.In addition to dail’s code, you should also add these 3 lines. I came up with this code thanks to Claudia’s previous code.
<pre><code>
editor:AssignCmdKey(3, SCMOD_CTRL, SCI_NULL) – CTRL + PAUSE/BREAK
editor:AssignCmdKey(7, SCMOD_SHIFT, SCI_NULL) – SHIFT + ESC
editor:AssignCmdKey(189, SCMOD_CTRL + SCMOD_SHIFT, SCI_NULL) – Ctrl + Shift + -(Dash)
</pre></code>On a side note, I can’t get the markdown for codeblocks to show up in a post’s preview.
-
Running
editor:AssignCmdKey(string.byte(‘E’), SCMOD_CTRL, SCI_NULL)
in the console did not change my key assignments.That’s weird. It works for me. Maybe there is some other plugin or keyboard configuration that is messing with it.
Thanks for those extra 3 shortcuts. They worked fine for me!
Also, to fully get rid of those ASCII control codes, you should probably disable those on both “views”. So instead of using
editor
you should set the shortcut on botheditor1
andeditor2
instead; for example…editor1:AssignCmdKey(3, SCMOD_CTRL, SCI_NULL) editor2:AssignCmdKey(3, SCMOD_CTRL, SCI_NULL)
I believe this would also apply to the PythonScript plugin.
-
Hi Danny and All,
Once you inhibited these shortcuts, you’re still able to write control characters, in your text, with the classical Windows method !
-
Hit down the ALT key
-
While keeping the ALT key pressed, type, on the NUMERIC keypad, the three digits, of a number between 001 and 031
-
Release all the keys => the appropriate Control character should be inserted, at the current cursor position
For instance : Press ALT and 0 , 1 , 8 would write the 18th letter of the alphabet ( the letter R ) => DC2
So :
ALT + 0 0 1 => SOH ( A ) ALT + 0 0 2 => STX ( B ) ALT + 0 0 3 => ETX ( C ) ALT + 0 0 4 => EOT ( D ) ALT + 0 0 5 => ENQ ( E ) ALT + 0 0 6 => ACK ( F ) ALT + 0 0 7 => BEL ( G ) ALT + 0 0 8 => BS ( H ) ALT + 0 0 9 => TAB ( I ) ALT + 0 1 0 => LF ( J ) ALT + 0 1 1 => VT ( K ) ALT + 0 1 2 => FF ( L ) ALT + 0 1 3 => CR ( M ) ALT + 0 1 4 => SO ( N ) ALT + 0 1 5 => SI ( O ) ALT + 0 1 6 => DLE ( P ) ALT + 0 1 7 => DC1 ( Q ) ALT + 0 1 8 => DC2 ( R ) ALT + 0 1 9 => DC3 ( S ) ALT + 0 2 0 => DC4 ( T ) ALT + 0 2 1 => NAK ( U ) ALT + 0 2 2 => SYN ( V ) ALT + 0 2 3 => ETB ( W ) ALT + 0 2 4 => CAN ( X ) ALT + 0 2 5 => EM ( Y ) ALT + 0 2 6 => SUB ( Z ) ALT + 0 2 7 => ESC ( ) ALT + 0 2 8 => FS ( ) ALT + 0 2 9 => GS ( ) ALT + 0 3 0 => RS ( ) ALT + 0 3 1 => US ( )
Only, the control character NULL can’t be written, with that method. Instead, you’ll use the ASCII Insertion Panel ( Menu Edit - Character Panel ! )
Cheers,
guy038
-
-
Hi @guy038,
yes, of course, the assignCmdKey is an scintilla internal function only.
Not sure if I get your point so.Cheers
Claudia -
if you are still interested in getting the python script code working I assume
you need to install the python script plugin by using the msi package.
It seems that plugin manager has some serious problems with this plugin.Cheers
Claudia -
Just noting that a similar thing is discussed in this thread as well:
https://notepad-plus-plus.org/community/topic/12901/shortcut-map-num-performs-function-but-also-adds/8 -
-
So using the luascript addon with those start-up lines https://community.notepad-plus-plus.org/topic/11233/disable-ascii-control-characters-shortcuts/5 is still the only way to do this?
-
-
Well, there are several ways to achieve it, but if you mean can Notepad++ alone achieve it, the answer is No, it can’t.
The disadvantage of the LuaScript approach might be that no one has “looped” it, and every discrete key must be handled. Perhaps I would “loop” it, if I knew Lua…
Anyway, another approach where you don’t have to list every key is with a PythonScript, such as the one shown HERE.
-
@Alan-Kilborn said in Disable ASCII Control characters shortcuts?:
if you mean can Notepad++ alone achieve it, the answer is No, it can’t.
@Claudia-Frank’s suggestion in 2016 seems to work. The following will disable nearly all of the keyboards combinations in @Danny-Phan’s original list.
<Macro name="RemoveKey_Shift_Esc_ESC" Ctrl="no" Alt="no" Shift="yes" Key="27"> <Action type="0" message="0" wParam="0" lParam="0" sParam="" /> </Macro> <Macro name="RemoveKey_Ctrl_E_ENQ" Ctrl="yes" Alt="no" Shift="no" Key="69"> <Action type="0" message="0" wParam="0" lParam="0" sParam="" /> </Macro> <Macro name="RemoveKey_Ctrl_R_DC2" Ctrl="yes" Alt="no" Shift="no" Key="82"> <Action type="0" message="0" wParam="0" lParam="0" sParam="" /> </Macro> <Macro name="RemoveKey_Ctrl_Shift_-_US" Ctrl="yes" Alt="no" Shift="yes" Key="189"> <Action type="0" message="0" wParam="0" lParam="0" sParam="" /> </Macro> <Macro name="RemoveKey_Ctrl_Shift_6_RS" Ctrl="yes" Alt="no" Shift="yes" Key="54"> <Action type="0" message="0" wParam="0" lParam="0" sParam="" /> </Macro> <Macro name="RemoveKey_Ctrl_Shift_A_SOH" Ctrl="yes" Alt="no" Shift="yes" Key="65"> <Action type="0" message="0" wParam="0" lParam="0" sParam="" /> </Macro> <Macro name="RemoveKey_Ctrl_Shift_C_ETX" Ctrl="yes" Alt="no" Shift="yes" Key="67"> <Action type="0" message="0" wParam="0" lParam="0" sParam="" /> </Macro> <Macro name="RemoveKey_Ctrl_Shift_D_EOT" Ctrl="yes" Alt="no" Shift="yes" Key="68"> <Action type="0" message="0" wParam="0" lParam="0" sParam="" /> </Macro> <Macro name="RemoveKey_Ctrl_Shift_H_BS" Ctrl="yes" Alt="no" Shift="yes" Key="72"> <Action type="0" message="0" wParam="0" lParam="0" sParam="" /> </Macro> <Macro name="RemoveKey_Ctrl_Shift_N_SO" Ctrl="yes" Alt="no" Shift="yes" Key="78"> <Action type="0" message="0" wParam="0" lParam="0" sParam="" /> </Macro> <Macro name="RemoveKey_Ctrl_Shift_O_SI" Ctrl="yes" Alt="no" Shift="yes" Key="79"> <Action type="0" message="0" wParam="0" lParam="0" sParam="" /> </Macro> <Macro name="RemoveKey_Ctrl_Shift_Y_EM" Ctrl="yes" Alt="no" Shift="yes" Key="89"> <Action type="0" message="0" wParam="0" lParam="0" sParam="" /> </Macro> <Macro name="RemoveKey_Ctrl_Shift_V_SYN" Ctrl="yes" Alt="no" Shift="yes" Key="86"> <Action type="0" message="0" wParam="0" lParam="0" sParam="" /> </Macro>
Some keyboard combinations from the original list are now being used by v8.6.2. If you are using an older version of Notepad++ then include these to intercept these keyboard combinations:
<Macro name="RemoveKey_Ctrl_Shift_B_STX" Ctrl="yes" Alt="no" Shift="yes" Key="66"> <Action type="" message="" wParam="" lParam="" sParam="" /> </Macro> <Macro name="RemoveKey_Ctrl_Shift_G_BEL" Ctrl="yes" Alt="no" Shift="yes" Key="71"> <Action type="" message="" wParam="" lParam="" sParam="" /> </Macro> <Macro name="RemoveKey_Ctrl_Shift_W_ETB" Ctrl="yes" Alt="no" Shift="yes" Key="87"> <Action type="" message="" wParam="" lParam="" sParam="" /> </Macro> <Macro name="RemoveKey_Ctrl_Shift_X_CAN" Ctrl="yes" Alt="no" Shift="yes" Key="88"> <Action type="" message="" wParam="" lParam="" sParam="" /> </Macro> <Macro name="RemoveKey_Ctrl_Shift_Z_SUB" Ctrl="yes" Alt="no" Shift="yes" Key="90"> <Action type="" message="" wParam="" lParam="" sParam="" /> </Macro>
I could not figure out how to handle
Ctrl+Pause/Break
. The code should be<Macro name="RemoveKey_Ctrl_Break_ETX" Ctrl="yes" Alt="no" Shift="no" Key="19"> <Action type="" message="" wParam="" lParam="" sParam="" /> </Macro>
but the
ETX
still shows up. I tried all eight combinations of Ctrl, Alt, Shift with key code 19 but none of them caughtCtrl+Pause/Break
. AsETX
shows up in the editor indicates it is getting a key code. Either it’s not code 19 or there is something else going on that’s special with Ctrl+Break. -