Pooya Karimian

Persian Javascript

Persian Keyboard Emulation with Javascript
[ About | Sample | Changes | Download | Discussion ]


Persian/Farsi keyboard emulation under IE/Mozilla/Firefox browsers using Javascript. This code is originally an implementation of National Iranian Keyboard Standard (ISIRI 2901:1994) from Roozbeh Pournader and Behdad Esfahbod but I made some changes to make it work under Firefox/Mozilla browsers too.
It is known to work under Internet Explorer 6.0 in Microsoft Windows and Mozilla and Firefox browsers in any Unicode supporting OS. This code is licensed under GNU General Public License.

Please report comments and bugs to info at_pooyak.com.

Sample usage

Try typing in the following textbox. CTRL+ALT changes language and SHIFT+SPACE inserts a Zero-Width-Non-Joiner character:

Persian / English
Click here for more info.


Update (2013-07-31): Artyom Lukanin, Firefox fix (isTrusted flag)

Update (2006-04-13): initKeyEvent is back in Firefox (Bug #303713).

Update (2005-12-02): I fixed vertical and horizontal scrolling in Firefox=>1.0.6. Although still horizontal scrolling has some small issues it works fine in most of the cases.

Update (2005-09-09): Thanks to Behdad and Artyom Lukanin the script is now working in Firefox => 1.0.6 too.

Update (2005-08-07): Seems like because of a vulnerability initkeyevent is disabled from Firefox 1.0.6 as you can see in bug #289940. I'm too busy but I will try to write a complete description and comment on that bug hoping that this feature returns back to Firefox.

Firefox on Windows up to version 1.0.x has problem with catching CTRL+ALT event. This problem is fixed in the nightly builds coming with Gecko 1.8b. Knowing that it will be fixed in the next Firefox release (1.1.x). I decided to leave the same key combination, because it is the best possible combination possible. You can change the source code to add extra shortcuts.


 - isiri2901.zip Package: JS Source with a sample HTML
 - isiri2901.js Javascript only

Other files / Old code

Original code was published on Persian Digital Library and FarsiTools project on SourceForge.

 - Iranian Keyboard Layout based on National Iranian Keyboard Standard (ISIRI 2901:1994).


Here you can ask your questions and leave your comments about this scripts.

[Click! It's fun. Or try it on the test page.]

Persian keyboard [Hide]

Salam Pooya, 

I was wondering if you know of any javascript code that would produce a persian keyboard. Some people were complaining that they either can't type using persian keyboard or don't have it at work. 


Persian keyboard [Hide]

Hi Mehdi,

I guess you mean a keyboard image that people can look at or type by clicking on it, is that right? There's this Behdad editor http://behdad.org/editor/ which uses this javascript code for the keypresses. There you can find the keyboard images. Knowing Behdad, I'm guessing that those images are GPL'ed as well. We can confirm it with him. 

But still that's not a clickable keyboard. But it shouldn't be that hard to implement. I look into it if you think it is needed.

Persian keyboard [Hide]

salam pooya jan
man ye site mp3 daram ke addressesh ro vared kardam www.mp3-ir.com agar beri tooie site mibini ke paeene page man ye ghesmate news gozashtam age bekham tiooie in farsi benevisam bayad chikar konam? chon vaghty ke az windows baraye in kar estefade mikonam aski code rad mishe

Persian keyboard [Hide]

I saw Behdad's after I saw your javascript.

Your draft keyboard looks promising. My knowledge of javascript is not that good. It would be great if you can drop the letters in a box. 


Persian keyboard [Hide]

Yes, me and Behdad decided to implement this and add it to javascript code. And referesh the page, cause i'm working on it right now.

Persian keyboard [Hide]

I am trying to change the language of three text boxes that I have in Submit page of balatarin. The don't have the same ID but I can give them the same Class. How can I use your code to convert all boxes with the same class? Is there a more elegant solution for it?


Persian keyboard [Hide]


mehrdad | 2013-03-26 18:39:12 |

FF2.0 compatible [Hide]

I'm very happy to see it works all fine in Firefox 2.0 :-)

Great work! [Hide]

Nicely done. Looking for more great works like this one. It is cool to see folks like you guys come up with solution like this...

type farsi [Hide]

man dombale yek barname migardam ke az tarighe oon betoonam farsi type konam va nemidoonam che barmaei ro bayad search konam lotfan mano rahnamai konid

P [Hide]

harf-e 'پ'- 'p <== farsi' moshkel darad

hkazemi | 2007-08-18 06:35:31 |

P [Hide]

No, that's not true. You probably try to press the "\" button to get "پ" similar to Microsoft Windows. But in the ISIRI 2901:1994 which is the Iran's standard layout you should press "M" to get "پ".

FireFox Error [Hide]

Ba Salam
با سلام
این ادیتور فارسی شما در مرورگر فایرفاکس درست کار نمی کند لطفا راهنمایی کنید.
ضروری است.
با تشکر از زحماتتان
Your Farsi editor does not work properly in FireFox Browser?
Please Help

FireFox Error [Hide]


Typing farsi on buttons [Hide]

I am trying to make some buttons with farsi language. I manage to write it but when i want to see the button in different browsers, then the text changes to ?????. Could you please guide me about that if you know about typing farsi in flase, dreamweawer or other tools.
with regards

Typing farsi on buttons [Hide]

I have the same problem, did you decide it?

Faridun | 2012-05-12 05:27:42 |

It doesn't type "Peh" [Hide]


This keyboard doesn't type "Peh" پ of persian alphabet

theone2003a | 2008-01-12 09:22:38 |

It doesn't type "Peh" [Hide]

It does. It is under "M" which is the Iranian standard. See the layout here: http://pooyak.com/p/persianjavascript/keyboard/

Thank and more suggest [Hide]

look at this:

improve this code with GUI with Javascript, it's so usefull.

thank and goodluck.

tashakor [Hide]

با تشکر موفق باشید

Hossein | 2008-02-24 23:34:56 |

linux [Hide]

با سلام و تشکر از امکان خوبی که ارائه کرده اید من این کد را استفاده کردم و براحتی در محیط سیستم عامل ویندوز مایکروسافت در تمام مرورگرها کار میکند ولی امروز متوجه شدم در سیستم عامل لینوکس کیبرد هیچ تایپی انجام نمیدهد لطفا راهنمائی کنید

hossein | 2008-04-20 02:32:02 |

Arabic keyboard [Hide]

I want to use ur script in an application that users can enter english & arabic languages. I noticed that the keyboard layout is Iranian and i need it arabic. Can i? How? Example when i press ] i need to get ج in arabic.

Samer Hussein | 2009-02-06 01:36:57 |

linux [Hide]

man systeme amelam Linux ast vali na mitavanam farsi bekhanam na benevisam. lotfan agar momkene rahnemaiee konid

Alireza | 2009-03-08 07:13:09 |

Thanks [Hide]

very thanks for interesting codes.
i could use from this code but still not implementation it in our site.

Chrome [Hide]

would you please make this code compatible with Google Chrome, cause this browser is somw how public too and some Users have problems.


Mehrad Mahmoudian | 2009-08-17 06:46:54 |

Thanks [Hide]

very thanks for this kind of  code.
But I need indian Language Supports  like Hindi,Urdu..........other than persian.How can i develop. 
plese assist me

Labtob [Hide]

متاسفانه این برنامه بر روی لب تاب کار نمی کند
من در چند لب تاب مختلف آنرا امتحان کردم و کار نکرد 
حتی همین صفحه در لب تاب فقط تایپ انگلیسی کار می کند و فارسی را تایپ نمی کند
در صورت امکان راهنمایی بفرمایید 
با تشکر

Google Chrom browser [Hide]

با سلام

با برسیهایی که انجام دادیم مشکل از لب تاپ نیست.
متاسفانه این برنامه در Google Chrom browser کار نمی کند
اگر امکان دارد مرا راهنمایی کنید.
با تشکر

thanks [Hide]

thank you because this example is with his source

Problem In change textarea to textbox in asp.net [Hide]

سلام و خسته نباشید
با تشکر فراون از زحمتی که کشیده ایدو منتشر کردید.من دوتا مشکل داشتم. اول اینکه وقتی به جای
قراردادم برنامه با مشگل مواجه شده و فقط 
تغییر می کند و زبان تغییر نمی کند.حتی کدهای جاوااسکریپت را هم
کردم با قبل هیج تفاوتی از نظر اجرای کد نداشت ولی در عمل با مشگل مواجه بود. 
مورد دوم: وقتی که زبان کیبورد فارسی باشد در دو حالت فارسی تایپ می شود یعنی با فشردن لینک انگلیسی و سپس تایپ در منطقه مشخص شده، فارسی تایپ می شود .
ممنون از وقتی که می ذارین .

shima sharif | 2011-01-18 00:50:16 |

determine language of keyboard on text box [Hide]

man to web sitam ye textbox daram k karbar mitoone toosh engelisi ya farsi type kone va man mikham k befahmam ba che zabani dare type mikone
lotfan komakam konin?

Mr [Hide]

با سلام 

متاسفانه این برنامه در 
کار نمی کند

Mr [Hide]

kheyli khoob bood

tnks [Hide]

thanks from your help

Mamnoon [Hide]

mamnoon az in javascript.
besyar khoob va perfevt bood,test kardam khieli aali bood.


فایرفاکس [Hide]

با تشکر از کد شما, این کد در فایرفاکس عمل نمیکند

فایرفاکس [Hide]

It is fixed now. Please test.

تركيب حروف و اعداد [Hide]

ممنمون. وقتي يك متن با تركيب حروف فارسي و انگليسي و عدد را تايپ مي كنيم هنگام خواندن مقدار اين كنترل متن را درست نمي دهد و جاي حروف و اعداد را به هم مي زند. لطفا راهنمايي كنيد. مرسي

تركيب حروف و اعداد [Hide]

من مشکلی با ترکیب English و فارسی نمی‌بینم. حتی وقتی از اعداد فارسی (۱۲۳۴) یا انگلیسی (1234) استفاده می‌کنم!

شما از چه browserی استفاده می‌کنید؟

Firefox 18.0.2 [Hide]

Dear Pooya,

I am using your Persian Javascript code already for a long time, and it is great! I noticed that the Persian characters do not appear when the latest version of Firefox is used (18.0.2). That's why I am writing this email in English! I wonder if you need to update anything in the code. Will you please have a look? 

Best regards, 
Fakhredin Sayed Tabatabaei.

Fakhredin | 2013-02-15 02:06:58 |

Firefox 18.0.2 [Hide]

It is fixed now. Please test.

Firefox 18.0.2 [Hide]

خیلی ممنون از از لطفی که کردید! 

فخرالدین | 2013-08-14 04:50:58 |

عدم کارکرد [Hide]

سلام پویا جان این کد شما توی مرورگر موزیلا در ورژن 19 که جدید ترین میباشد عمل نمیکند لطفا بررسی فرمائید

سعید | 2013-03-18 22:45:09 |

عدم کارکرد [Hide]

It is fixed now. Please test.

Char Code [Hide]

Hi Pooya,
I need farsi char code when i fire up next line in javascript:
var Char = String.formCharCode(event.keyCode);
Normally this line returns standard char code in English, I need it in farsi. Can you help me?

Faramarz | 2013-07-28 08:35:31 |

IE 11 problem [Hide]

your above sample not working in the IE 11.

sadcds [Hide]


یطزیس | 2015-10-01 19:31:31 |

Safari / Mac implementation [Hide]

is there any chance to get this script working on Safari, both for Windows and Mac? If I switch the keyboard to "Persian", it doesn't type anything if opened in Safari. We could pay for this job, if it's possible. Let me know!
[Friday 2015-11-27] [Updated Saturday 2013-11-30]