# Align Arabic typed response - language style RTL/Arabic doesn't work in textboxes

**URL:** <https://discourse.psychopy.org/t/align-arabic-typed-response-language-style-rtl-arabic-doesnt-work-in-textboxes/25674>\
**Category:** Online experiments\
**Created:** [October 28, 2021, 12:22pm UTC](https://discourse.psychopy.org/t/align-arabic-typed-response-language-style-rtl-arabic-doesnt-work-in-textboxes/25674 "2021-10-28T12:22:19Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ghoza\_Elottee](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/ghoza_elottee/32/11751_2.png) [@Ghoza\_Elottee](https://discourse.psychopy.org/u/Ghoza_Elottee)\
**Post date:** [October 28, 2021, 12:22pm UTC](https://discourse.psychopy.org/t/align-arabic-typed-response-language-style-rtl-arabic-doesnt-work-in-textboxes/25674/1 "2021-10-28T12:22:19Z")

</div>

**What did you try to make it work?:**  
I’m trying to run an experiment using textbox with Arabic language which follows right to left language style. I still got the Arabic letters written from left to right even when I changed the style to Arabic and RTL style.

In the English version of the study I used the following codes for as follows:

in begin experiment tab I have:

**inputText3 = ""**

In begin experiment tab:

**inputText3 = ""**  
**actualKeys=""**  
**shift\_flag = False**  
**event.clearEvents(‘keyboard’)**

In each frame tab I have:

actualKeys = event.getKeys()  
n = len(actualKeys)  
i = 0  
while i \< n:  
if actualKeys[i] == ‘return’:  
continueRoutine = False  
break  
elif actualKeys[i] == ‘backspace’:  
inputText3 = inputText3[:-1] # lose the final character  
i = i + 1  
elif actualKeys[i] == ‘space’:  
inputText3 += ’ ’  
i = i + 1  
elif actualKeys[i] in [‘minus’, ‘-’, ‘num\_subtract’, ‘Minus’, ‘slash’]:  
inputText3 += ‘-’  
i = i + 1  
elif actualKeys[i] in [‘lshift’, ‘rshift’, ‘SHIFT’]:  
shift\_flag = True  
i = i + 1  
else:  
if len(actualKeys[i]) == 1:  
if shift\_flag:  
inputText3 += actualKeys[i].upper()  
shift\_flag = False  
else:  
inputText3 += actualKeys[i]  
i = i + 1  
In end routine tab:

**thisExp.addData(“typedWord3”, inputText3)**  
**inputText = ""**

but these codes are not working at all in the Arabic version. I tried the text box and at least I got the Arabic letters displayed in the screen but in the wrong alignment (LTR).

I’m not sure if I need specific coding and whether or not there a way to make it using textbox?

Thank you  
Ghozayel

---

<div class="post-metadata">

**Author:** ![mark.a.j.scott](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/mark.a.j.scott/32/4649_2.png) [@mark.a.j.scott](https://discourse.psychopy.org/u/mark.a.j.scott)\
**Post date:** [November 2, 2021, 7:42pm UTC](https://discourse.psychopy.org/t/align-arabic-typed-response-language-style-rtl-arabic-doesnt-work-in-textboxes/25674/2 "2021-11-02T19:42:38Z")

</div>

Hi,  
Python has a well known issue with Arabic. It can’t get the kerning right. The simplest work-around is to use a word processor to write the text you want to use as stimuli and convert them into images (just taking a screenshot will work if you don’t have access to a “cleaner” method). If you display them as images, they won’t be altered by Python’s text processing.  
Good luck,  
Mark

---

<div class="post-metadata">

**Author:** ![Ghoza\_Elottee](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/ghoza_elottee/32/11751_2.png) [@Ghoza\_Elottee](https://discourse.psychopy.org/u/Ghoza_Elottee)\
**Post date:** [November 3, 2021, 4:52pm UTC](https://discourse.psychopy.org/t/align-arabic-typed-response-language-style-rtl-arabic-doesnt-work-in-textboxes/25674/3 "2021-11-03T16:52:28Z")

</div>

Hi Mark,

Thank you for your reply and suggestion. I’ve actually followed your suggested solution with the Arabic text I want to display on the screen, it works, thank you. However, I need to come up with a solution for text entries from participants, i.e. typing an Arabic script as a response to a question. I hope there’s a sort of trick that can make it happen ☹

Best,  
Ghozayel
