# When should key appear on display?

#### mukesh1

Joined Mar 22, 2020
67
There are many systems that have a matrix keypad and an LCD such as calculator, password based door lock system.

i have general question.What should we keep in mind while designing such a system.

1. When should key appear on display?

if the key is first pressed or if the key is released.

2. What should happens if the key is pressed and held down continuously?

#### click_here

Joined Sep 22, 2020
533
It's very much a feel thing

I personally feel that a password based lock system or a calculator shouldn't repeat a key when held down, because they require precise inputs and there is no reason to put a random amount of a certain character.

#### atferrari

Joined Jan 6, 2004
4,574
There are many systems that have a matrix keypad and an LCD such as calculator, password based door lock system.

i have general question.What should we keep in mind while designing such a system.

1. When should key appear on display?

if the key is first pressed or if the key is released.

2. What should happens if the key is pressed and held down continuously?
The basic questions that come to mind:

Does the user need to see the result of the key just being pressed down?

Should the result be displayed at all? If so, for a short or long period?

I find obvious that if the result is to be displayed, it should appear immediately.

Your second question could be answered by deciding what YOU, the designer, need to happen when a specific key is pressed down.

BTW, adding confusion to your questions: what if more than one key is pressed simultaneously?

#### BobaMosfet

Joined Jul 1, 2009
1,942
There are many systems that have a matrix keypad and an LCD such as calculator, password based door lock system.

i have general question.What should we keep in mind while designing such a system.

1. When should key appear on display?

if the key is first pressed or if the key is released.

2. What should happens if the key is pressed and held down continuously?
This is a logic question.
1. A key should appear when the user presses it, following a debounce to be sure the key is valid.
2. If a key is held down- what do you want it to do? Repeat or not- that is your decision based on your needs. Repeating keys are fine, so long as there is a delay after the first press. Heuristics show that a person cannot react faster than a 10th of a second, so there is your window.

I've done this on many systems, and it works flawlessly.

#### MrChips

Joined Oct 2, 2009
25,919
There are three key-switch actions:
1) Key pressed
2) Key held down
3) Key released

For a large number of applications, the following functions should be executed:
1) Key pressed - debounce and display key icon. If the key is a function key, e.g. Enter, then the function is executed.
2) Key held down - no function
3) Key released - no function, except no new key-pressed is acknowledged until all keys are released. Again debouncing is required.

#### mukesh1

Joined Mar 22, 2020
67
2) Key held down - no function
3) Key released - no function,
What do you mean by no function? Does it mean the new key wasn't pressed yet

#### MrChips

Joined Oct 2, 2009
25,919
What do you mean by no function? Does it mean the new key wasn't pressed yet
It means that you do nothing.

#### KeithWalker

Joined Jul 10, 2017
2,295
You are the designer so the key functions should work the way you design them to work. How they work depends on the application and how you want them to work.

#### ErnieM

Joined Apr 24, 2011
8,271
Show the press when the user presses it.

If I press a button and nothing happens I press that sucker even harder.

#### click_here

Joined Sep 22, 2020
533
Here is some very basic C with a lot of functionality missing, but you'll get the idea
Code:
for(;;)
{
bool buttonPressed;

//Wait for press
do
{
buttonPressed = isButtonPressed();
}
while(!buttonPressed);

handleButtonPress();

delayForBouncingToStop();

// wait for release
do
{
buttonPressed = isButtonPressed();
}
while(buttonPressed);

}
Basically, wait for a press, do something, delay for bouncing, and then wait for release.