Wait a minute, Mhz,
Kevin's counter doesn't output the number of pulses that you want, and neither does his multiplexer.
A counter can be preset by a binary input to a certain number that it starts counting from. Then its outputs count up or down from there. You could preset it to "5" from the keyboard's encoder and have it stop when it counts down and reaches "0". With a multi-input gate connected to all counter outputs and the clock, the output of the gate will be the 5 clock pulses that you want. The same thing will happen with any other keyboard-to-preset number.
One kind of multiplexer simply "selects" multiple inputs and outputs them, one at a time, usually in sequence. Another kind of multiplexer simply "steps" its multiple outputs, one at a time, and has a single input. I don't see any requirement for a multiplexer in this circuit. Kevin says that the multiplexer "selects", but there is nothing to select from, since there is only one keyboard encoder that can directly feed the counter's presets. A keyboard encoder sometimes has a multiplexer built into it, but that is also not required here.
You will need additional circuitry such as a flip-flop and a multiple-input gate from the encoder to start the clock when you press a button and to keep it going until the counter output reaches "0".