Abnormal trailing ^ on input

8 次查看(过去 30 天)
Jose M Soler
Jose M Soler 2024-9-26
I have suddenly run into a strange problem. Now, when pressing ^, my command line (not the editor) enters an abnormal state, writing ^ (underscored) AFTER the last of any subsequent input characters. The trailing ^ only disappears after pressing Enter (without its usual effect). The problem prevails after exiting and reopening matlab, and even after restarting the computer. Any solution or hint?
  4 个评论
Stephen23
Stephen23 2024-9-26
Many keyboard layouts use a dead key for the caret: https://kbdlayout.info/features/deadkeys
Are you using one of those?
José María
José María 2024-9-26
移动:Voss 2024-9-26
Thaks for all the comments.
Yes, I am using Ubuntu 24.04 and a Spanish keyboard with dead keys.
Normally, I type ^ and nothing appears, then I press the space bar and ^ appears, and then I type the next character. The problem arose while I was typing in the command line, but I do not remember the exact sequence of keys. No error message.
Now, when I press ^, it already appears underscored. If I continue typing, everything appears BEFORE the underscored ^. The spacebar has no effect. The backspace key erases that typed text but not the trailing ^. The Enter key does supress the trailing ^ and recovers normal typing (without executing the command).

请先登录,再进行评论。

回答(2 个)

Sumukh
Sumukh 2024-9-27
Hi Jose,
You can try out the following workarounds for the issue:
  1. The “power” function can be used instead of the “^” operator.
  2. Disable the dead key sequences. This prevents from using the characters that correspond to these sequences. There are two ways to disable the dead keys: using “setxkbmap” or “dpkg-reconfigure”.
Use setxkbmap
Before starting MATLAB, from the shell prompt type
setxkbmap -variant nodeadkeys
After exiting MATLAB, from the shell prompt type
setxkbmap -variant basic
Use dpkg-reconfigure
Type
dpkg-reconfigure xserver-xfree86
When the system prompts you to select the keyboard variant, choose nodeadkeys.
3. Remap the keys, i.e., use a different key combination for entering the “^” character. This remaps the key for all applications for the entire session, not just for MATLAB. The change only works for the current session, so you must remap the key again after you log off and log back on. Please follow these steps to remap a key using the command “xmodmap”:
  • Determine the key you want to use as a substitute for the “^” operator. For example, you could remap the F11 key to type a caret (^).
  • Use “xmodmap” to see what your current keymap looks like:
xmodmap -pke | more
This displays a table of values and a description of the behavior for each key.
Note the line that contains the key you want to remap. As an example, for a Finnish Keyboard, the line might be:
95 0xffc8 (F11)
  • Find the decimal representation of the ASCII key that you want to map.
Most Linux systems display a map when you run this command:
man ascii
The output includes the following:
The Ascii value of the caret (^) character is decimal 94.
  • Remap the key using xmodmap. To set the F11 key to input a caret (^) character, type:
xmodmap -e "keycode 95 = 94"
  • Test the new key binding.
I hope this helps resolve the issue.

Jose M Soler
Jose M Soler 2024-9-27
Hi Sumukh,
thanks for all your suggestions but I was not able to solve the problem with them.
Incidentally, my key encoding is UTF-8, my ascii decimal number for ^ is 30 and
the key for ^ is Shift+key34 in my keyboard.
I kept exploring different keystroke behaviors:
- The anomalous behavior starts with any dead key (i.e. the accents ',`,",^), not only ^.
- After the anomalous behavior starts, you can input any sequence of characters,
inluding the dead keys (with their normal delayed appearence). But everything appears
before the trailing underscored ^.
- The trailing ^ disappears after you press Enter (without other effects).
- The input string executes normally after a second Enter.
- The problem does not affect the matlab editor, the linux terminal, nor any other
editor or program.
Thus, I have the impression that the problem is not with the key encodings but rather
with a special state of the command line, prompted by the dead keys. I have checked
also the shortcuts but found nothing suspicious (I did not add any).
Incidentally, I have unadvertently used two different MathWorks accounts
(from my home and sabbatical host universities). I apologize for that.

类别

Help CenterFile Exchange 中查找有关 Matrix Indexing 的更多信息

产品


版本

R2024b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by