Arrow keys moves the cursor in opposite direction when I type Hebrew. Is there any solution? Thanks
Asked
Active
Viewed 316 times
0
-
This is the default convention of windows editors, If you want the mac editor behavior too, try opening github feature request about this. – a user Aug 29 '19 at 11:07
1 Answers
-2
There is an open GitHub issue concerning this problem. Unfortunately, it seems that a real right-to-left support is not implemented yet.
Anyways, you could try one of the following approaches for a workaround solution:
1) Use the CSS direction
property in your Ace container to force the right-to-left rendering. Although it's rather about text styling, maybe it could help.
2) If that doesn't help, you can try to catch arrow events and send "fake events" instead (see this StackOverflow post for code reference):
function triggerFakeKeyEvent(keycode) {
let keyboardEvent = document.createEvent("KeyboardEvent");
let initMethod = typeof keyboardEvent.initKeyboardEvent !== 'undefined' ? "initKeyboardEvent" : "initKeyEvent";
keyboardEvent[initMethod](
"keydown", // event type: keydown, keyup, keypress
true, // bubbles
true, // cancelable
window, // view: should be window
false, // ctrlKey
false, // altKey
false, // shiftKey
false, // metaKey
keycode, // keyCode: unsigned long - the virtual key code, else 0
0 // charCode: unsigned long - the Unicode character associated with the depressed key, else 0
);
document.dispatchEvent(keyboardEvent);
}
document.addEventListener('keydown', function(event) {
// left arrow key
if(event.keyCode === 37) {
event.preventDefault(); // ignore the original keyboard event
triggerFakeKeyEvent(39);
}
// right arrow key
else if(event.keyCode === 39) {
event.preventDefault(); // ignore the original keyboard event
triggerFakeKeyEvent(37);
}
});

SparkFountain
- 2,110
- 15
- 35
-
-
The event isn't performs when the focus is on the editor. In the rest of the document is working. I'm thinking to attach your code to: editor.textInput.getElement() – Yalon Keret Aug 29 '19 at 09:42