How Does a Matrix Keyboard Scanning Algorithm Work?

Keyboard Matrix

A Matrix Keyboard Scanning Algorithm is an algorithm that a microprocessor uses to search a keyboard matrix to determine if any of the keys are pressed.

This is how a keyboard matrix works:

When no key is pressed, all columns read high. Any key being pressed will cause one of the columns to go low (the column that contains the key that was pressed). So, to see if a key has been pressed, a microprocessor only needs to see if any of the input lines are low. Once the microprocessor has detected that a key has been pressed, it just needs to find out which key it was. This process is quite simple. As mentioned, the microprocessor first detects the column and then it detects the row of the column of the pressed key. The key can only be on one row, so the microprocessor outputs a low on only one of the rows. If it finds a 0 (low) on the input port, the microprocessor knows that the pressed key occurred on the selected row. Conversely, if the input port had all highs, the key pressed was not on that row and the microprocessor selects the next row, repeating the process until it finds the row. Once the row has been identified, the specific column of the pressed key can be established by locating the position of the single low bit on the input port.

HTML Comment Box is loading comments...