viridi wrote:
Could something like this work?
I use port A of the 6522 to scan through the columns and rows using a 74238 (columns) and a 74151 (rows). When a key is pressed pin Q of the 74151 will be high that is passed to port B of the 6522. Then I know on which row and column a key is pressed.
Here is a schematic:
Attachment:
ViridiKeyboard.jpg
I just added all 64 possible keys I probably will remove some of them as I might not need them.
This can work, but consider that the multiplexer is expecting only one row to be active at a time. If you expect to have key combinations such as Shift+Letter (as I expect you will with only 64 or less keys) you will need to make sure to pick locations where it is unlikely two or more keys will get pressed/read in the same column at the same time.
To put it another way, if column 3 is the one you're currently scanning, and keys on rows 2 and 4 are both pressed, you won't be able to tell both are down, the multiplexer is just going to pick one.
Many PC keyboards did/do this to save on costs though, and as I say, they tried to arrange the keys in such a way that multiple combinations where unlikely to come up. If you can accept this, then it is a good way to go, if not you'll want to be able to check each row independently.
There are of course plenty of way to do this and still save on pins on your 6522 if you're trying to keep some around for other things. (E.g. reading game controllers)
At the risk of summoning some ire, Ben Eater mentions this in one of his videos on the PS/2 keyboard:
https://www.youtube.com/watch?v=2lPzTU-3ONI