Suppose we have 3 keyboards and we take out all the switches. Would we call these objects still "keyboards"? Someone could argue that these objects don't have switches so they can't be called "keyboards" since switches is a main characteristic of a keyboard. But one also could argue that these object are "keyboards" from which have been removed the switches. I came up with this question when I thought what will I answer if someone asks me how many keyboards are there? Would 3 or 0 be the right answer?
In short form, it depends on how you WANT to define keyboard.
What you are getting at is a question about the nature of definition. This is related to the ancient problem known as the ship of Theseus. 'What makes something what it is' is a very ontological question, but what you've spotted is an issue raised by Ludwig Wittgenstein and his observation of family resemblances. Traditionally, philosophers have gravitated towards necessity and sufficiency as a way to define words using use-mention distinction. A 'keyboard' is anything that is a keyboard doesn't really solve the question of what is the fundamental essence of a keyboard. You rightfully point out that a keyboard that doesn't function might not be a useful keyboard, but still appears to be one. Like the ship of Theseus, we can even make this more interesting by asking 'at what point if I remove keys, will it still be a keyboard'. If it's a keyboard with 101 keys, and one breaks, it's reasonable to call it a keyboard, and yet if it has no functioning keys, not really much of one at all.
You could qualify. Broken keyboard. Keyboard prop. Non-functional keyboard. That could be one way of answering the question, but the questions raised point in the direction of what is known as graded membership like in fuzzy logic. Instead of binary true and false, in or out of categories, it is or it isn't, one can simply ask to what degree. A keyboard with no switches is not a keyboard, and one with a quarter functioning is somewhat a keyboard, and if it has almost all, then it's almost a complete keyboard. I suspect, however, that most people surveyed would still consider a broken keyboard, a keyboard. The reason for that is grounded in what linguistics tells us about how the brain categorizes. From WP's article on Prototype theory:
Wittgenstein's theory of family resemblance describes the phenomenon when people group concepts based on a series of overlapping features, rather than by one feature which exists throughout all members of the category. For example, basketball and baseball share the use of a ball, and baseball and chess share the feature of a winner, etc, rather than one defining feature of "games". Therefore, there is a distance between focal, or prototypical members of the category, and those that continue outwards from them, linked by shared features.
Prototype theory was inspired by latter Wittgenstein's family resemblance observation and holds that necessity and sufficiency is insufficient to describe how our brains categorize. Rather, there are a general set of qualities that an object has, and no one quality or property is absolutely essential. Take a chair. Most chairs have four legs, but if you take away one, is it still a chair? Sure. Many chairs have arm rests, but not all. Does a chair need a tall back, or one at all? Most would consider a chair without a back a stool, but at what height does the back make a stool a chair? Does a chair have to have a certain height?
This is where the question of normativity comes into play. How a keyboard is defined may depend on the context. An electronics manufacturing consortium would have a need for a different definition, say a precising definition than an end-user. A legislative body interested in a legal definition which is technical in a different sense, and would be broad to ensure, for example, that more rather than fewer 'keyboards' are taxed. Ambrose Bierce is famous for satirical definitions to entertain. (He might write today 'A "keyboard" is any device used in front of monitors for catching crumbs, dirt, and spilled liquids, and holds the distinction of being originally designed specifically to slow down typing.)
A broken chair (not a broken piece) is a chair if it has almost the shape of a chair. Similarly a broken keyboard is a keyboard. Don't you call it a keyboard if a tiny inner-part, soldering is gone, OR if there is a loose contact in it? Similarly a keyboard without keys can be called a keyboard because it was a keyboard earlier and it has the shape of a keyboard. But you can't call it a keyboard until it is not fully assembled.
Don't you call your friend whose arm is amputated, a man/woman/human-being? Since the arm is not the main part we never call the amputated arm a man/woman/human-being even if it had life earlier.
So if somebody asks, you can reply that the number of keyboards is three. But you should use your common sense according to the context. Eg. If you are a keyboard seller normally you cannot deal it as a keyboard (when selling). But if you are buying it for scrap you may deal it as a keyboard (when buying).
Limits of functional definition
Functional definition (of a object) is a definition based on a (primary) function. In our case , definition would be something like "keyboard is an object used for typing letters and other signs". Of course, this definition could be further clarified (connected to a computer or typewriter, has keys to be pressed, etc ...) but basically it that does not define keyboard by its structure (made of plastic, has wires etc.. ) or it resemblance to other objects (rectangular, thin, looks like board etc ..). Instead it uses function (typing).
Question now arises, what would happen with non-functioning keyboard ? We could define it as "broken", but this is also imprecise. For example, if we ground our keyboard to a powder, is it still broken ? Or, are only reparable keyboards still keyboards (and what is reparable exactly ) ?
As you can see, functional definitions are not perfect, but same could be said about other types of definitions (structural, by resemblance etc .. ) . In fact, only certain thing is that human language and human categorization only vaguely portray phenomena of (human) experience, things that we perceive as reality. In practice, as mentioned in an answer by J D, there are various definition for the same class of object. Electrical engineers would prefer structural definition, lawyers gravitate towards functional definition and children are best instructed with definitions based on resemblance (of already familiar objects).