Disable ASCII Control characters shortcuts?
-
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. -
-
@Alan-Kilborn said in Disable ASCII Control characters shortcuts?:
but if you mean can Notepad++ alone achieve it, the answer is No, it can’t.
In light of @mkupper 's post, I’ll qualify mine:
I sensed the recent poster was looking for a simple checkbox of the form:
- Disallow control character entry via typing
And, as that preference setting doesn’t exist, I said it couldn’t be done with Notepad++.
Obviously, one can come up with a list of unassigned Ctrl+??? combinations and create do-nothing macros for all of them (I suppose there aren’t too many).
However, I’d suggest assigning a SCI_NULL operation to them; SCI_NULL is Scintilla command id 2172.
-
Thanks @mkupper! It looks like the way to implement that would be to edit the
shortcuts.xml
file and paste in those lines you shared.
npp-user-manual dot org/docs/macros/
I guess for the Scintilla method we edit the same file with a similar format, replacing the existing
<ScintillaKeys />
line.For now, I’ve just assigned basic hotkeys to the main ones I was having trouble with.
-
@MaximilianKohler said in Disable ASCII Control characters shortcuts?:
It looks like the way to implement that would be to edit the shortcuts.xml file and paste in those lines you shared.
npp-user-manual dot org/docs/macros/That is correct. I have not looked at github yet to see if there is not already a feature request too add a setting
Ignore unrecognized keyboard Ctrl codes
. I don’t know if it would be easy or hard to implement as I don’t know if the fall-through path for unrecognized keyboard codes is in Notepad++, meaning it should be easy to code, or if keystrokes are passed to Scintilla in hopes that they are recognized.My guess is that the unrecognized keystrokes go to Scintilla which then passes then on to Windows. Applications such as Notepad++ are supposed to look for things that they care about and pass the rest on to Scintilla which looks for things it cares about and passes the rest on to Windows. Windows’ keystroke handler will be looking for Alt-F4 and similar things and converting them into messages such as WM_QUIT to exit the application.
Thus, it may well not be at all easy for Notepad++ to have an
Ignore unrecognized keyboard Ctrl codes
setting. -
@mkupper said in Disable ASCII Control characters shortcuts?:
it may well not be at all easy for Notepad++ to have an Ignore unrecognized keyboard Ctrl codes setting.
Actually, it should be fairly easy.
And the script I linked to yesterday (and everyone since then has so far ignored) shows what would need to be done:
Prevent WM_CHAR codes for the control character range from reaching Scintilla, where they are processed by putting the corresponding character in the document.
By the way, people in the future will come read this thread, so it is best to post “correct” information.
This is not how to define a correct action tag to solve the problem; one example from above:
<Macro name="RemoveKey_Ctrl_Shift_X_CAN" Ctrl="yes" Alt="no" Shift="yes" Key="88"> <Action type="" message="" wParam="" lParam="" sParam="" /> </Macro>
The correct equivalent would be:
<Macro name="RemoveKey_Ctrl_Shift_X_CAN" Ctrl="yes" Alt="no" Shift="no" Key="88"> <Action type="0" message="2172" wParam="0" lParam="0" sParam="" /> </Macro>
Reference: https://npp-user-manual.org/docs/config-files/#macros:~:text=Attributes for the <Action> tag
-
-