I have a project to control the CPU fan so that I have to send PWM signal and get the fan speed dynamically.
I read the following website and implemented this way.
Now I'd like to use the keypad to adjust the fan duty or input some parameters, but there is a 1 second time delay while processing fan speed. It seems it interferes the keypad collecting.
How can I add the keypad function in such a situation?
The code you mention uses a delay(1000) which causes the CPU to stop, wait 1 second, then continue. This causes what you refer to as the 1 second time delay while processing. That is why the delay is constantly bashed for being what is referred to as "blocking". During delay, the CPU is blocked.
There is an entire post here in this Forum to handle this issue because it constantly Comes up.
Refer to: https://www.arduino.cc/en/Tutorial/BlinkWithoutDelay
Though the sample blinks an LED, the concept is the same.
The demo Several Things at a Time is an extended example of BWoD and illustrates the use of millis() to manage timing. It may help with understanding the technique.