لوحة مفاتيح عربية

Ergonomic Arabic Keyboard Layout

لؤلؤة

This is work in progress and contributions are welcome. Head over to GitHub to see where you can help.

Goals

  • Ergonomic typing of unvocalized and vocalized text with 10 fingers
  • Modern Standard Arabic and Quranic Arabic
  • Localized numbers (European/Arabic-Indic)
  • Usable as primary or secondary keyboard
  • Compose-based
  • Support for Markdown, RST, Wikitext and similar markup

Other languages using the Arabic alphabet (regional dialects, Urdu, Persian) are explicitly not supported.

Usage

Printout
PDF
Windows
Download driver and follow instructions in INSTALL.txt
Android
Install AnySoftKeyboard and Arabic for AnySoftKeyboard
Linux
Run: xmodmap ar-lulua.xmodmap
Klavaro
A touch typing tutor. Copy the custom keyboard to %localappdata%\klavaro (Windows) or ~/.config/klavaro/ (Linux), select Keyboard → (Custom), then lulua_ar.

Learn more

الأبجدية العربية

The Arabic alphabet

28 letters make up the Arabic alphabet and quite a few extra symbols are required for proper text input, like the hamzah (ء) in its different shapes أ إ آ ء ئ ؤ, tāᵓ marbūṭah (ة), ᵓalif maqṣūrah (ى) and various diacritics for vowelized texts. Since the performance of a keyboard layout depends on the text entered it is necessary to study its mono-, di- and trigraph frequencies first. The novel corpus built for the following analysis consists of

مصدركلامحروف
الجزيرة ٥٤٧٬١١٠ مقالة ١٨٩٫٤ مليون ١٫٢ مليار
ويكيبيديا العربية ٨٥٧٬٣٨٦ مقالة ١١٠٫٨ مليون ٧٠٢٫٢ مليون
بي بي سي العربية ١٤٩٬٩٠١ مقالة ٣٦٫٩ مليون ٢٣٣٫٣ مليون
هنداوي ٢٬٢٢٧ كتاب ٩٠٫٧ مليون ٦٦٥٫٠ مليون
خريطة الشارع المفتوحة Arabic Labels ٣٧٦٬١٤٨ labels ٩١٠٫١ ألف ٥٫٥ مليون
ORPUS OpenSubtitles 2018 ٩٤٬٠٩٣ فيلم ٣٦٣٫٩ مليون ٢٫١ مليار
القرآن (من tanzil.net) ٧٨٫٢ ألف ٧٠٣٫٨ ألف
الأمم المتحدة Parallel Corpus v1.0 ١١٦٬٧٥٤ ملف ٤٢٤٫٣ مليون ٢٫٩ مليار
مجموع ١٫٢ مليار ٧٫٨ مليار
SourceWordsCharacters
Al-Jazeera 547,110 articles 189.4 million   1.2 billion
Arabic Wikipedia 857,386 articles 110.8 million 702.2 million
BBC Arabic 149,901 articles  36.9 million 233.3 million
hindawi.org   2,227 books  90.7 million 665.0 million
OpenStreetMap Arabic Labels 376,148 labels 910.1 thousand   5.5 million
ORPUS OpenSubtitles 2018  94,093 movies 363.9 million   2.1 billion
tanzil.net Quran  78.2 thousand 703.8 thousand
United Nations Parallel Corpus v1.0 116,754 documents 424.3 million   2.9 billion
Total   1.2 billion   7.8 billion

The chosen Quran representation does not include all quranic diacritization symbols, like other datasets. This makes comparison fairer, since most keyboards presented below do not include any of them.

The plot below shows ᵓalif (ا), lām (ل), yāᵓ (ي), mīm (م), wāw (و) and nūn (ن) can be considered the most frequently used letters in the Arabic language. Together they account for more than 55% of all letters in the corpus.

Arabic letter frequency distribution

Layout properties

Throughout this evaluation color coding is used to identify fingers:

red
little finger
blue
ring finger
magenta
middle finger
violet
index finger
cyan
thumb

Asymmetry is defined as the difference between left and right hand button usage \(b_{left/right}\) and includes the thumb:

$$a = \frac{b_{left}}{b_{total}} - \frac{b_{right}}{b_{total}}$$

The layout proposed uses four shift layers in a way inspired by Neo2. Thus it assumes a 102/105 key ISO keyboard common in Europe – but also available in Arab countries – to accommodate for the necessary shift keys. These are in order: Shift on the left and right, caps lock on the left and the rightmost key in the middle row, the key right to the left shift key and the key labeled Alt Gr to the right of the spacebar. Symbols are assigned to the four layers by their function: characters, punctuation, diacritics, other.

Apple, for instance, provides an Arabic hardware keyboard with this physical layout. But both variants, 101/104 key and 102/105 key devices, seem to exist in the Arab world.

The first layer was optimized using an extended reimplementation of carpalx. From several runs with 100.000 iterations each the layout which had good scores and looked reasonable to the human eye was picked. Afterwards the third layer was optimized using the same process, but only using data from the Hindawi corpus, because it is the only one with at least some fully diacriticised texts. Finally the different brackets were arranged by hand and the remaining symbols algorithmically distributed on the second layer using the raw Wikitext from the Arabic Wikipedia dataset.

This is a common way of arranging brackets, because most algorithms ignore human desire for symmetry.

The most frequent letters have all been assigned to the home row, which makes them easily accessible. ᵓAlif (ا) and lām (ل) are typed with different hands, balancing the load on hands almost evenly. The index and middle finger of both hands share the majority of the typing load, but naturally the left middle finger is used more frequently due to its assignment to the letter ᵓalif (ا).

The layout targets Quaranic and Modern Standard Arabic (MSA), also called Fuṣḥa (الفصحى), only. Dialectical Arabic (العامية) is mainly a spoken language, although with the rise of social media sites like Twitter and Facebook this is changing. For now however it’s not an optimization target due to the lack of a good, representative corpus.

Designing the layout to be compose-based has both benefits and disadvantages. Compose-based mainly means the hamzah (ء) is treated like an optional diacritic for ᵓalif (ا), wāw (و) and yāᵓ (ي) instead of viewing ᵓalif-hamzah (أ), wāw-hamzah (ؤ) and yāᵓ-hamzah (ئ) as precombined, atomic units. Although ᵓalif-hamzah and ᵓalif are not the same, the hamzah can be dropped if the writer’s intention is unambigiously inferable from context. Thus it makes sense to provide hamzah as a combining character on the keyboard. Additionally it uses two keys less than precombining it with its stems, allowing the entire alphabet plus hamzah diacritic to fit on a single keyboard layer. However, there is a cost to this approach: All hamzah variants account for 3.0% of button combinations. Splitting hamzah and from its stem means doubling the total number of button combinations and thus button presses, decreasing scores like words per minute (WPM) slightly. Splitting ᵓalif (ا) and ᵓalif-hamzah (أ) could also reduce pressure on left middle finger and allow for more even distribution, since 1⁄5th of all ᵓalif (ا) uses are with hamzah (ء).

See for example section 3.3 of Buckwalter’s Issues in Arabic Morphological Analysis.

49.86%
6.34
6.01
16.13
13.50
7.88
Asymmetry: -0.003
50.14%
7.93
18.72
10.57
6.11
6.79

Acknowledgements

This work would not have been possible without Martin Krzywinski’s work on carpalx. Neo Layout’s kbdneo2 Windows driver proved to be an invaluable source for understanding the undocumented nature of Windows keyboard driver development.