for anything more complex that a light switch, the flash will be the least expensive way to go - as mentioned above, what we are talking about is a micro-controller, not a dedicated flash memory chip like that used to store the music (or whatever) in a mp3 player. The smallest of these are US $1 Retail in single quantity. order a million and they are likely 20 cents tops. A slightly larger one will have enough pins for the keys on the keyboard and spit USB out the other end, along with enough extra pins to act as a USB Hub, light the LEDs for caps lock, and still have pins left over for factory testing. 1 chip is all you need ( yes it might be cheaper to use dumb logic to multiplex the pins from the keyboard buttons - in fact it is - the difference is a few cents but over a few million it adds up - i am attempting to make the simple argument )
And this chip is still well under $1.
With one of these i can use the same chip in every keyboard i design. The logic design for all my keyboards never needs to change - so i need to only stock 1 pc board for all keyboards - just flash the correct firmware before it goes into the keyboard. If someone lays out the pc board wrong - i may well be able to fix this problem in the firmware. I want to make a trackball, a joystick, a WOW keyboard - same chip, same logic pc board, just slightly different firmware - some guy in marketing wants to add an LED, same chip - same pc board
This same thing is what makes it possible to 'flash' BIOS. In "The Old Days" Bios was an expensive, custom memory chip . You had to change out the chip itself to upgrade the BIOS. So you had to disassemble the computer, so you needed someone who could do this, ... it was expensive to make a change, it was not easy to add a feature, like support for a new drive. and so on..
Today all BIOS is FLASH - and the flash is either inside a micro-controller, or (and more often the case) the memory has its own micro-controller and this is what handles all of the heavy lifting for a BIOS upgrade - it programs the BIOS memory. And everyone of these BIOS micro-controllers has extra RAM and FLASH hanging around, it makes upgrades easy and cheap. Problems that used to cost millions to fix are now only a download away.
These micro-controllers are everywhere today - they run the fancy display of car stereos - the graphics - the security code for detachable faceplates - all in one of these little things. The same is true for home stereos - it is cheaper to install one of these on the pc board with the display than to pay for the bigger connectors that would be needed otherwise. It really can be, and often is, cheaper than wire. And again use the same pc board, just flash new software into it, and the marketing guys have new features - or at least flashing lights - for the cost of changing some code. The left over memory in this chip is what allows for fancy 'demo' displays on electronics - the memory is there - let the marketing guys fill it with whatever they want. The other guys add a 'cool' feature - add your own without even slowing down the assembly line ( yes testing .... i know )
Anywhere you see cool flashing lights, or a small add on feature, on a piece of electronics, it is likely that one of these micro controllers is what is making that happen. You want serial and not USB - easy - , you want to make you product compatible with another guys new product - easy, you want to change the length of time on the wash cycle of your dishwasher so that it can get a better rating in Consumer Reports - easy -
Every keyboard has a similar problem - just happened to be exploited on a Mac first.
And if you are looking for a career in electronics/computer science/engineering - embedded design can be fun