This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
agowa338's profile picture

edit "CTRL" and German Keyboard

Started by agowa338, 08 March 2015 - 02:30 PM
agowa338 #1
Posted 08 March 2015 - 03:30 PM
VERSION:
The version of ComputerCraft the bug happened in is any.
DESCRIPTION:
If you're using a German Keyboard you cannot easily insert characters like for example { [ ] }
This happens because the menu of the edit command is opened using "CTRL" and on German keyboards you have to press "AltGr" and one of 7890.
The Turtle is recognizing this as "CTRL".
EXPECTED RESULT:
Writing characters like { [ ] }
REPRODUCTION STEPS:
Open edit command and type {[]} using a German keyboard.
Lignum #2
Posted 08 March 2015 - 05:38 PM
There's a workaround for this: Press AltGr, release it and then press your desired key combination while it's in the menu. It's annoying but it works.
agowa338 #3
Posted 08 March 2015 - 06:41 PM
I know this workaround, but it's still an annoying bug.
GopherAtl #4
Posted 08 March 2015 - 07:12 PM
fairly certain this issue can be resolved by editing /rom/programs/edit (outside of cc, obviously, since you can't edit rom in-game) and changing line 538 from:

  elseif param == keys.leftCtrl or param == keys.rightCtrl then

to:

  elseif param == keys.leftCtrl or param == keys.rightCtrl or param == keys.rightAlt then

because altgr seems, under the hood, to send a leftCtrl key event followed by an rightAlt key event. I can only test this with virtual keyboard settings, and only on a windows system, but with windows told to use a german keyboard layout, this is allowing me to type the characters directly.

For all our non-english-language-keyboard using CC'ers, it would be very nice if dan200 would incorporate this change into the next version, but in the mean time, if people with actual, physical non-qwerty keyboards could test and confirm whether or not this works, it would be very helpful!

For conveinence in testing, I've put a modified version of edit on pastebin, just grab it with the following command at shell:

pastebin get b86LNJ1q edit2
then try it out by doing "edit2 newfile" and trying to type some of these problem characters, and report back the results here.
Edited on 08 March 2015 - 06:15 PM
agowa338 #5
Posted 08 March 2015 - 08:26 PM
Your edit2 solves the problem.
But I just noticed, that the CTRL key on the right side isn't working in both (standard edit and your edit2). Is this the same with the English keyboard layout?
GopherAtl #6
Posted 08 March 2015 - 08:40 PM
Your edit2 solves the problem.
But I just noticed, that the CTRL key on the right side isn't working in both (standard edit and your edit2). Is this the same with the English keyboard layout?

huh; I almost never touch the right-ctrl key, just noticed it's generating a key event with code 157, but keys.rightCtrl is 153. so it doesn't work in for a my standard us keyboard, either.
Edited on 08 March 2015 - 07:41 PM
Cranium #7
Posted 10 March 2015 - 06:27 PM
This actually has nothing to do with how ComputerCraft interprets the keypresses at all, with exception to Lua interpretation which you've already got a workaround for. It's due to how the LWJGL interprets the keypresses and sends them to ComputerCraft. The LWJGL that Minecraft uses interprets US standard IBM keyboard presses, so doesn't know any difference when it comes to how your OS uses those key combinations on other keyboards.
Seems fixed to me :D/>
Edited on 01 April 2015 - 02:27 PM
dan200 #8
Posted 01 April 2015 - 02:15 PM
I've implemented the fix suggested by gopherAtl for the next version