Ruling on using an electronic rak‘ah-counter whilst praying
Question

                Is it permissible to use an electronic counter that counts automatically, without any intervention from the worshipper or anyone else, to count the number of rak‘ahs that the worshipper does, so that he can be certain of the number of rak‘ahs that he has prayed, in the event of error or forgetfulness, whether in an obligatory or naafil prayer? I have produced a device that does this, and it works on the basis of a very small detector (with a thickness of 1-2mm) that is placed under the prayer mat or directly beneath the forehead of the worshipper, and it counts the number of prostrations, on the basis of which it works out the number of rak‘ahs that the worshipper has done, then it shows them on a small digital screen in front of the worshipper. If you need more explanation, I can send some pictures or a video to show how it works. Please advise me, may Allah bless you.
Praise be to Allah.
		Firstly: 

	Counting the number of rak‘ahs in the prayer is something for 
	which there is a precedent in the practice and words of the early 
	generations. Their methods of counting varied according to their 
	environments and times. Some of them used to use their rings, some used date 
	stones or pebbles, and others used their fingers or toes. All of this 
	confirms that there is a basis for using such a device to count the number 
	of prostrations and rak‘ahs. 

	Ibn Rajab al-Hanbali (may Allah have mercy on him) said:
	

	Al-Fadl ibn Shaadhaan quoted in his book ‘Add al-Aayi 
	wa’r-Rak ‘aat fi’s-Salaah the hadith of ‘Abd ar-Rahmaan ibn al-Qaasim 
	from his father, from ‘Aa’ishah, according to which, when she offered an 
	obligatory prayer, she would count her prayer with her ring, moving it on 
	her hand until she finished her prayer, and counting with it.

	End quote from al-Khawaatim by Ibn Rajab (p. 109). The 
	isnaad going back to ‘Aa’ishah is saheeh. 

	Al-Kharashi al-Maaliki (may Allah have mercy on him) said:

	Moving the ring from one finger to another in order to count 
	the rak‘ahs when one is afraid of forgetting does not come under the heading 
	of fidgeting, because that is being done in the interests of the prayer.

	End quote from Sharh Mukhtasar Khaleel (1/294) 

	In Haashiyat Ibn ‘Aabideen (1/650) it says: 

	It says in al-Bahr: With regard to moving the tips of 
	the fingers (to keep count) or counting in one’s mind, that is not makrooh, 
	according to consensus, but counting out loud spoils the prayer, according 
	to consensus. End quote. 

	Muhammad al-Baabirti al-Hanafi (may Allah have mercy on him) 
	said:

	… It was narrated from Abu Yoosuf and Muhammad that there is 
	nothing wrong with counting on the hand. He mentioned the hand specifically, 
	because moving the tips of the fingers (to keep count) or counting in one’s 
	mind is not makrooh, according to consensus, but he warned against counting 
	out loud, because it spoils the prayer.

	End quote from al-‘Inaayah Sharh al-Hidaayah (1/418) 

	Shaykh al-‘Uthaymeen (may Allah have mercy on him) said:

	He may count the number of rak‘ahs, and there may be a need 
	to do so, because many people may forget and resort to counting them on 
	their fingers, in which case there is a problem, because when the worshipper 
	bows, he has to spread his fingers, and when he prostrates, his fingers must 
	be straight. Therefore he may count them using pebbles or date stones. So he 
	can put four dates stones in his pocket, then when he has prayed the first 
	rak‘ah, he can move one of them, and so on until they are finished. There is 
	nothing wrong with this, because there is a need for it, especially when one 
	is very forgetful. 

	End quote from ash-Sharh al-Mumti‘ ‘ala Zaad al-Mustaqni‘ 
	(3/249, 250). 

	Secondly: 

	But in the case of this counter and similar inventions, there 
	are a number of concerns: 

	1.
	The worshipper may be distracted by looking at it and 
	thinking about its numbers. In most cases he will not be content with the 
	number of the sajdah or rak‘ah until he thinks it over so that he may be 
	sure that it is correct. This is something that may cause the device to miss 
	its original purpose, which is to help one to focus in prayer and not be 
	distracted by anything outside the prayer.

	2.
	There are essential parts and obligatory acts in the 
	prayer that the device does not take into account. There may be a mistake in 
	the recitation of al-Faatihah, or the worshipper may forget to sit for the 
	first tashahhud, or he may not bow at all, but the device may count it as a 
	rak‘ah because he prostrated twice! In which case the benefit from it may be 
	limited or completely absent. Similar problems may arise if there is a 
	prostration of recitation (sujood at-tilaawah) during the prayer.

	Thirdly: 

	With regard to our opinion concerning this device and similar 
	devices, we say: 

	Islam came to enjoin presence of mind when praying, and it 
	has prescribed clear rulings for the one who loses focus and makes mistakes 
	in his prayer. If he loses focus and does not know how many rak‘ahs he has 
	prayed, then he should proceed on the basis of the lower number, then do the 
	prostration of forgetfulness before saying the salaam. It is also prescribed 
	for him to seek refuge with Allah from the Shaytaan and to spit drily to his 
	left when he realises that he has become distracted in his prayer. 

	What we think is that it is permissible and useful for one 
	who is faced with compulsive whispers, or is very forgetful and that is 
	causing him some difficulties, if it will benefit him in his prayer and will 
	fulfil its purpose by helping him to focus on his prayer. But in ordinary 
	cases, when there is no particular need for such things, we do not think 
	that a person should use it; rather there is the fear that it may come under 
	the heading of blameworthy unnecessary effort and things that people have 
	introduced into the matter of worship that are detrimental to the original 
	purpose of focusing the heart on Allah, and praying with proper humility, so 
	you see him giving free rein to the thoughts and whispers that come to him, 
	relying on the device to count his prayer for him! 

	And Allah knows best.