Open Sahnvour opened 3 years ago
French dev here, having this issue is a deal breaker, since I can't type any of the ~#{[|\^@]}
and ` chars while nog is running.
Here's my workaround in the meantime, using the all powerfull Autohotkey to script the sending of the character :
; NOG ALT-GR OVERWRITE
; <^>! is Ctrl+Alt = AltGr
; the first ` in Send during {Text} mode is the autohotkey escape char
<^>!é::Send {Text}`~
<^>!"::Send {Text}`#
<^>!'::Send {Text}`{
<^>!(::Send {Text}`[
<^>!-::Send {Text}`|
<^>!è::Send {Text}``
<^>!_::Send {Text}`\
<^>!ç::Send {Text}`^
<^>!à::Send {Text}`@
<^>!)::Send {Text}`]
<^>!=::Send {Text}`}
@Sahnvour Do you have a keybinding which uses Alt + E
?
We are using the RegisterHotKey function for keybindings and I can't see AltGr as a valid modifier. Maybe we have to do some winapi magic for this?
I don't have a particular binding on Alt+E
, that was my example but as @branch3 said, the problem concerns any character typically produced with AltGr.
We are using the RegisterHotKey function for keybindings and I can't see AltGr as a valid modifier. Maybe we have to do some winapi magic for this?
My bet is that windows translates AltGr to Ctrl+Alt, but what we want here is more like a physical keycode. Sadly I don't know this part of the windows API.
I setup a french keyboard on my windows machine to check this out and while I don't have a solution, I might have a workaround.
Pressing AltGr does register to Nog as Ctrl+Alt as stated above, but the reason it "swallows" is because, I'm assuming, @Sahnvour and @branch3 may have Nog configured to do something on Ctrl+Alt+numbers.
Depending on what branch you're on the configuration might be different but I believe the default config binds Ctrl+Alt+(1-10) to be "Move Workspace to Monitor" and Ctrl+Alt+W to toggle work mode
// NOG config file (from development branch?)
bind "Alt+Control+W" toggle_work_mode();
bind_range 1 10 "Alt+Control" move_workspace_to_monitor;
// NS config file (from custom-language branch)
bind_arr("Alt+Control", nog.workspace.move_to_monitor, range(workspace_count))
Nog "swallows" the keybinding for "{" (AltGr + 4) as it is seeing it as "Alt+Ctrl+4" which is the keybinding for "move workspace to monitor 4." If you don't have a 4th monitor then it just looks like nothing happens.
Workaround I was able to type ~#{[|\^@]} and ` after changing the config to not have any Alt+Ctrl keybindings.
As @TimUntersberger said, there isn't an AltGr modifier in RegisterHotKey so we're unable to differentiate between that and Ctrl+Alt but as long as your keybindings don't overlap with AltGr usage you should be able to make things work and could also purposefully bind Ctrl+Alt on keys that aren't used with AltGr and that should work fine.
I looked for a way to detect this and it looks like most applications also check whether the left or right alt key was pressed. AltGr
uses the right Alt
key (source)
Newest development release contains an attempt at fixing this.
Not sure how anyone else feels about this but I actually do use my left and right alt keys in nog keybindings. I made a draft commit here that adds an "allow_right_alt" config value so users can opt into using the right alt key with nog.
Is this something that others would find useful?
@Sahnvour did my solution work?
@TimUntersberger Thanks, tested with the latest development release.
It seems to work fine, but I had to remove the the bind_range 1 10 "Alt+Control" move_workspace_to_monitor;
as proposed by @ramirezmike.
Before that, AltGr characters would only work for €
(E
), ]
(°
) and }
(+
). In other words, special characters on the number keys of the number row would not work.
Also it enabled firefox to be handled correctly which wasn't the case before that (not sure why).
Here's my config for reference:
disable launch_on_startup;
enable work_mode;
enable use_border;
enable display_app_bar;
disable remove_task_bar;
bind "Alt+Q" close_tile();
bind "Alt+M" minimize_tile();
bind "Alt+X" quit();
bind "Alt+H" focus("Left");
bind "Alt+J" focus("Down");
bind "Alt+K" focus("Up");
bind "Alt+L" focus("Right");
bind "Alt+Control+H" swap("Left");
bind "Alt+Control+J" swap("Down");
bind "Alt+Control+K" swap("Up");
bind "Alt+Control+L" swap("Right");
bind "Alt+V" split("Vertical");
bind "Alt+B" split("Horizontal");
bind "Alt+Control+W" toggle_work_mode();
bind "Alt+F" toggle_fullscreen();
bind "Alt+Enter" launch("C:\\Program Files\\ConEmu\\ConEmu64.exe");
bind_range 1 10 "Alt+Shift" move_to_workspace;
bind_range 1 10 "Alt" change_workspace;
rule ".*- Mozilla Firefox|Mozilla Firefox" #{
has_custom_titlebar: true,
firefox: true,
};
rule ".*- Visual Studio Code" #{
has_custom_titlebar: true
};
Also it enabled firefox to be handled correctly which wasn't the case before that (not sure why).
@Sahnvour
I believe the latest development release uses config.ns (the new nogscript syntax) instead of config.nog (the old rhai syntax). You should see a config.ns file in the same folder. An example config can be found here. It's possible what you're seeing might be because of this switching of config files?
The new syntax should be pretty straightforward to convert your settings too although feedback on that is definitely welcome.
@Sahnvour is this now working for you?
@TimUntersberger just tested with the latest development release.
The behaviour is the same as reported in my last comment (using the new .ns
config files from your example).
It works fine if I remove the following line:
nog.bind_arr("Alt+Control", nog.workspace.move_to_monitor, range(workspace_count))
For now, I don't mind this workaround as I don't use multiple monitors.
It works fine if I remove the following line:
nog.bind_arr("Alt+Control", nog.workspace.move_to_monitor, range(workspace_count))
For now, I don't mind this workaround as I don't use multiple monitors.
@Sahnvour just for the record in case you or anyone else wants to use multiple monitors, the problem is specifically binding Alt+Control + anything you'd use AltGr with.
Nog "swallows" the keybinding for "{" (AltGr + 4) as it is seeing it as "Alt+Ctrl+4" which is the keybinding for "move workspace to monitor 4." If you don't have a 4th monitor then it just looks like nothing happens. there isn't an AltGr modifier in RegisterHotKey so we're unable to differentiate between that and Ctrl+Alt but as long as your keybindings don't overlap with AltGr usage you should be able to make things work and could also purposefully bind Ctrl+Alt on keys that aren't used with AltGr and that should work fine.
If you want to bind move_to_monitor (or anything else) you just need to make sure you're not overwriting an AltGr + Key behavior. You could change the binding to this and it would work since it doesn't collide with anything AltGr uses
nog.bind_arr("Alt+Shift+Control", nog.workspace.move_to_monitor, range(workspace_count))
To put it differently, hypothetically it's the same thing that would happen if you bound something to Shift + A. You would no longer be able to capitalize "A" with the shift key because nog hijacks it. To nog, Alt + Control is equal to AltGr.
That's what I figured. It would still be nice to differentiate AltGr and Ctrl+Alt if possible, but that's not big of a deal.
@Sahnvour if you are not using the right alt key you shouldn't actually have any problems, since we now differentiate between left and right (AltGr is Control + RAlt). I think this should be a bug? Don't know whether we can fix it though.
@Sahnvour has this been fixed for you?
Version (which release did you use?) Development branch release
Describe the bug
When nog is active, I can't type some characters of my keyboard. Non-english languages have characters outside ascii range, often typed by a combination of
Alt Gr + <another key>
.It's more or less equivalent to typing
Ctrl+Alt+<another key>
, so I guess it's being caught by nog and does not produce the expected character.To Reproduce
Launch nog with a non-qwerty layout, for example I'm using french azerty. Try AltGr+E in a text field.
Expected behavior
It produces the character
€
.Actual behavior
It does not produce any character.