Using caret (circumflex) key for a shortcut
-
Hi,
I want to use the caret key (^), also known as circumflex, for a shortcut.
I’m using the shortcut Ctrl-^ in NetBeans to “go to matching brace” and want to have identical shortcuts. In NPP it is Ctrl-b by default.
Interestingly, Ctrl-^ in NPP does “anything”, something like Ctrl-Right, but in a different way.
When trying to assign a new shorcut to this function (Shortcut id=“43009”), I realized that this character is not included in the list of available keys…
As this key seems to be “not user-assignable”, it looks it is “internally hard coded” ?
Is there a reason for that ?
Can it be added somehow ?I tried to find out how shurtcuts are stored and tried another combination: Ctrl - 1 (after removing this from another function).
This combination works.Then I had a look into “shortcuts.xml” and I found the definition:
<Shortcut id=“43009” Ctrl=“yes” Alt=“no” Shift=“no” Key=“49” />
(Function is "Search for corresponding bracket, originally Ctrl-b)
As 49 is the decimal ASCII code of “1”, I tried to tamper the file and changes 49 to 94, the ASCII code of ^.
Unfortunately it does not work this way and when looking at the current shortcut config within NPP it shows “Ctrl+unlisted” / “confict found”.Is there any possibility to get this realized ?
Thank you and best regards !
-
‘^’ on my keyboard is actually Shift+6. Couldn’t you use Ctrl+6 as the shortcut and physically on the keyboard, the keystroke would be the same as you currently do?
-
Welcome, @Egon-Olsen, to the Notepad++ Community. You said:
As this key seems to be “not user-assignable”, it looks it is “internally hard coded” ?
Is there a reason for that ?
Unfortunately it does not work this way and when looking at the current shortcut config within NPP it shows “Ctrl+unlisted” / “confict found”.
Is there any possibility to get this realized ?When I tried to set a shortcut using the Settings > Shortcut Mapper, the
^
caret key doesn’t even show up. I believe this is because^
isn’t a separate key (on a standard US keyboard): it’s theShift+6
key (US).So if you want the keystroke to be
Ctrl+^
, that’s the same asCtrl+Shift+6
. That, you can easily map in the Shortcut Mapper, or by the following line in your shortcuts.xml:<Shortcut id="43009" Ctrl="yes" Alt="no" Shift="yes" Key="54" />
(Remember that if you edit shortcuts.xml in Notepad++, you must not have changed any settings in the current session; the best advice is close all Notepad++ instances, open Notepad++ and edit shortcuts.xml; save and exit Notepad++; reload, and the change should take effect. But I find it easier to change in the Shortcut Mapper)
edit: or, as @Michael-Vincent posted while I was typing this, you could just use the
Ctrl+6
, if you don’t want to hit the extra shift key; I don’t know which you would prefer. -
Thank you for your answers !
When I set the shortcut to Ctrl-6 or Ctrl-Shift-6 (via Settings > Shortcut Mapper) NPP did “exactly what I expected” - it jumps between the matching braces as soon as I press Ctrl-6 or Ctrl-Shift-6…
Unfortunately Ctrl-^ still does what it did before: something like Ctrl-Right, but in a different way.
I did not expect that it could be important to know what keyboard I am using… :-)
It’s a German keyboard.
The caret key is the key between ESC and TAB. It is used for ^ and with Shift: °
https://en.wikipedia.org/wiki/File:KB_Germany.svgAnyway, this key is “weird” too, as nothing happens when you press it once, as it “may” belong to the following character: a,e,i,o,u: â,ê,î,ô,û. “VERY” special characters… :-)
The character only shows up when you press it twice, or an other “second” key with a character which is not “coompatible” with ^.But this behavior is “normal”.
Also, as this is working like a charm in NetBeans, it cannot be a general issue.For comparison:
US:
https://en.wikipedia.org/wiki/File:KB_United_States-NoAltGr.svgand UK:
https://en.wikipedia.org/wiki/File:KB_United_Kingdom.svgI just “discovered” that this key seems to be the “backtick” (or backquote) key on the US/UK keyboard !
But… unfortunately this key also isn’t in the list of usagle keys in NPP… :-(
Any ideas ?
Thank you and best regard !
-
@Egon-Olsen said:
Anyway, this key is “weird” too, as nothing happens when you press it once, as it “may” belong to the following character: a,e,i,o,u: â,ê,î,ô,û. “VERY” special characters… :-)
The character only shows up when you press it twice, or an other “second” key with a character which is not “coompatible” with ^.Interesting. Glad I included “on a standard US keyboard”. :-)
Also, as this is working like a charm in NetBeans, it cannot be a general issue.
Well NetBeans may have implemented it in a very different way (I don’t know, because I don’t know the guts-details in NPP, and know nothing about the NetBeans). However, based on the way that it shows up in NPP shortcuts.xml, and my smattering of knowledge about keycodes vs characters, etc… I am guessing that the German layout has some special keycode for the fancy-^ key, which doesn’t line up with the ASCII code for
^
. Maybe if you found a utility that shows you the keycode of your keystroke (I know such exist; I don’t have one to recommend off the top of my head), you can see what keycode is sent… then maybe try to edit the shortcuts.xml to use that keycode instead of the “54” (6
) or “94” (^
). But it may be that the shortcut-implementation in NPP is incompatible with the special-^ key on a German keyboard. -
it seems that, on german keyboard, CTRL+^ can be mapped as CTRL+\
Btw. thank you for the hint. I’m using npp quite some time now but I never discovered ctrl+ ^ can do something useful. :-) -
Yeah !
Ctrl-\ is mapped to “SCI_WORDPARTRIGHT” - that sounds VERY promising :-)…and IT IS WORKING the way I want !!!
:-)But: VERY self-explaining that you has to use \ if you want ^…
Thank you !
-
But: VERY self-explaining that you has to use \ if you want ^…
LOL - I thought so to. Without the info that it jumps to the right, I never would have tried it
and I never would have look what kind of scintilla message could probably be used :-D -
@Egon-Olsen said:
I just “discovered” that this key seems to be the “backtick” (or backquote) key on the US/UK keyboard !
But… unfortunately this key also isn’t in the list of usagle keys in NPP… :-(
??? It is there!
Backtick is also called the grave-accent key and looks like this:
`
-
@Egon-Olsen , @Alan-Kilborn , @Ekopalypse
Yeah, it’s the old new thing about keyboard layouts.
On all PC keyboards world wide, no matter of which locale, keys have the same scan codes depending on their physical position on the keyboard. The keyboard driver for a certain locale translates them (under Windows) into virtual key codes. That’s what applications see when they read keyboard input. These virtual key codes are translated into the actual glyphs of the characters (at the end of the day a bitmap image) when they are displayed on the screen.
If the keyboard driver supports so called “dead keys” it waits for a second key press to compose them to a resulting character, e.g. all these â,ê,î,ô,û,… letters used in various european languages. This way there are not so much weird key combos to input these characters.
Unfortunately, in the shortcut mapper of Notepad++ all this isn’t taken into account. The person who programmed the key selector has used a hard coded table for the mapping of physical keys to their character representation, which is wrong for most locales. I wasn’t able to figure out yet, which keyboard locale this person used as a basis for the mapping.
This is the mapping table for german keyboards between the key list in Notepad++'s shortcut mapper and the physical keys:
| Npp shortcut mapper | German Keyboard | | |---------+------------| | | solo | with SHIFT | |---------------------+---------+------------| | ~ | ö | Ö | | - | - | _ | | = | + | * | | [ | ß | ? | | ] | ´ (DK) | ` (DK) | | ; | ü | Ü | | ' | ä | Ä | | \ | ^ (DK) | ° | | , | , | ; | | . | . | : | | / | # | ' | | <> | < | > |
(DK)
marks dead keys.I often thought about filing an issue about that but I think it will be nothing more than another forgotten minor bug in the issue tracker…