CN110221709B - Key detection method, keyboard and key system - Google Patents

Key detection method, keyboard and key system Download PDF

Info

Publication number
CN110221709B
CN110221709B CN201910453021.1A CN201910453021A CN110221709B CN 110221709 B CN110221709 B CN 110221709B CN 201910453021 A CN201910453021 A CN 201910453021A CN 110221709 B CN110221709 B CN 110221709B
Authority
CN
China
Prior art keywords
key
level
pressing
detection pin
preset
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201910453021.1A
Other languages
Chinese (zh)
Other versions
CN110221709A (en
Inventor
李书新
李双全
钟文涛
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Shenzhen Chaoku Technology Co ltd
Original Assignee
Shenzhen Chaoku Technology Co ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Shenzhen Chaoku Technology Co ltd filed Critical Shenzhen Chaoku Technology Co ltd
Priority to CN201910453021.1A priority Critical patent/CN110221709B/en
Publication of CN110221709A publication Critical patent/CN110221709A/en
Application granted granted Critical
Publication of CN110221709B publication Critical patent/CN110221709B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
    • G06F3/01Input arrangements or combined input and output arrangements for interaction between user and computer
    • G06F3/02Input arrangements using manually operated switches, e.g. using keyboards or dials
    • G06F3/023Arrangements for converting discrete items of information into a coded form, e.g. arrangements for interpreting keyboard generated codes as alphanumeric codes, operand codes or instruction codes

Abstract

The invention relates to the field of key detection, and discloses a key detection method, a keyboard and a key system. The key detection method is applied to a keyboard, and comprises the following steps: when a key event occurs, detecting a level change signal of a key detection pin connected with the key; when the key detection pin generates level jump for the first time, acquiring a first level of the key detection pin after jumping, wherein the first level is located in a leading edge jitter area of the level change signal; and executing a key pressing subprogram of the key in the front-edge jitter area according to the level type of the first level and the level type of a preset pressing level, and stopping detecting a level change signal of the key detection pin. The embodiment of the invention is not influenced by the front-edge jitter signal, and the response speed of key execution is improved.

Description

Key detection method, keyboard and key system
Technical Field
The present invention relates to the field of key detection, and in particular, to a key detection method, a keyboard, and a key system.
Background
The key detection method is widely applied to key input modules of various devices, such as keyboards and the like, and is used for detecting key events including key pressing and key releasing, so that the simplest man-machine interaction is realized.
At present, after the preset time is delayed, the level change signal of the key detection pin is obtained to avoid the influence of the front edge jitter signal on the key detection result. However, for special application scenarios, such as game competitions, even a millisecond-level delay may be enough to change the game result, and the jitter-free delay may cause the response time of the key pressing sub-program to be increased, and the sensitivity of the key to be reduced. In order to solve the above problem, an embodiment of the present invention provides a solution for increasing the response speed of key execution on the premise of being not affected by the leading edge jitter signal.
Disclosure of Invention
The embodiment of the invention provides a key detection method, a keyboard and a key system, which are not influenced by a front-edge jitter signal and improve the response speed of key execution.
In order to solve the above technical problems, embodiments of the present invention provide the following technical solutions:
in a first aspect, an embodiment of the present invention provides a key detection method applied to a keyboard, where the method includes:
when a key event occurs, detecting a level change signal of a key detection pin connected with the key;
when the key detection pin generates level jump for the first time, acquiring a first level of the key detection pin after jumping, wherein the first level is located in a leading edge jitter area of the level change signal;
and executing a key pressing subprogram of the key in the front-edge jitter area according to the level type of the first level and the level type of a preset pressing level, and stopping detecting a level change signal of the key detection pin.
In some embodiments, the method further comprises:
after delaying for a first preset time, continuously detecting a level change signal of the key detection pin, and acquiring a second level of the key detection pin at a corresponding moment;
and determining the key state of the key according to the level type of the second level and the level type of the preset pressing level.
In some embodiments, the key state comprises a key unreleased state;
determining the key state of the key according to the level type of the second level and the level type of the preset pressing level, wherein the determining comprises the following steps:
judging whether the level type of the second level is the same as the level type of the preset pressing level;
if so, determining that the key state of the key is a key unreleased state;
if not, executing a key release subprogram of the key, and stopping detecting the level change signal of the key detection pin.
In some embodiments, after determining that the key state of the key is a key unreleased state, the method further includes:
when the key detection pin has level jump again, acquiring a third level of the key detection pin after jumping;
judging whether the level type of the third level is the same as the level type of a preset release level;
if yes, executing a key release subprogram of the key, and stopping detecting the key detection pin;
and if not, returning to continuously detect the level change signal of the key detection pin.
In some embodiments, the key state comprises a key released state;
after executing the key release subroutine of the key, the method further comprises:
after delaying the second preset time, continuously detecting a level change signal of the key detection pin, and acquiring a fourth level of the key detection pin at a corresponding moment;
judging whether the level type of the fourth level is the same as the level type of the preset release level;
if yes, determining the key state of the key to be a key released state;
and if not, returning to continuously detect the level change signal of the key detection pin.
In some embodiments, when the preset press-down level is a low level, the preset release level is a high level;
and when the preset pressing level is a high level, the preset release level is a low level.
In some embodiments, the method further comprises:
counting the pressing times of the keys;
and adjusting the first preset time length and/or the second preset time length according to the number of times of pressing the key.
In some embodiments, the adjusting the first preset time period or the second preset time period according to the number of times the key is pressed includes:
judging whether the pressing times of the key is greater than a preset time threshold value or not;
if so, prolonging the first preset time and/or the second preset time;
if not, keeping the first preset time length and/or the second preset time length.
In some embodiments, the keyboard comprises a single-key keyboard;
the executing a key pressing subprogram of the key in the leading edge jitter area according to the level type of the first level and the level type of a preset pressing level comprises:
judging whether the level type of the first level is the same as the level type of a preset pressing level;
if yes, executing a key pressing subprogram of the key in the front edge jitter area, and stopping detecting a level change signal of the key detection pin;
and if not, returning to continuously detect the level change signal of the key detection pin.
In some embodiments, the keyboard comprises a matrix keyboard comprising a number of columns and rows of pins that are interdigitated;
the executing a key pressing subprogram of the key in the leading edge jitter area according to the level type of the first level and the level type of a preset pressing level comprises:
judging whether the level type of the first level is the same as the level type of a preset pressing level or not;
if yes, scanning column pins or row pins of all keys in the matrix keyboard;
determining coordinate information of the column pins and the row pins with changed signals;
determining a pressed key according to the coordinate information of the column pins and the row pins with the changed signals;
executing a key pressing subprogram of the key in the front edge shaking area;
and if not, returning to continuously detect the level change signal of the key detection pin.
In a second aspect, embodiments of the present invention provide a keyboard comprising:
pressing a key;
the key trigger circuit comprises an input end and an output end, and the input end of the key trigger circuit is connected with the key;
the controller comprises at least one key detection pin, and the at least one key detection pin is connected with the output end of the key trigger circuit;
wherein the controller includes:
at least one processor; and the number of the first and second groups,
a memory communicatively coupled to the at least one processor; wherein the content of the first and second substances,
the memory stores instructions executable by the at least one processor to enable the at least one processor to perform a key detection method as described in any one of the above.
In some embodiments, the keyboard comprises a single-key keyboard;
the key trigger circuit is a pull-up trigger circuit or a pull-down trigger circuit.
In some embodiments, the keyboard comprises a matrix keyboard;
the key trigger circuit comprises an AND gate and a plurality of pull-up resistors, each pull-up resistor is connected with a column pin of a key in the matrix keyboard, the column pins of all the keys in the matrix keyboard are connected to the input end of the AND gate, the row pins of all the keys in the matrix keyboard are connected to the input and output pins of the controller, and the output end of the AND gate is connected with the key detection pin of the controller.
In a third aspect, embodiments of the present invention provide a key system comprising:
a transmission bus;
the main controller is connected with the transmission bus;
a plurality of the keyboards of any of the above claims, each of the keyboards being connected to the transmission bus.
The embodiment of the invention has the beneficial effects that: different from the prior art, embodiments of the present invention provide a key detection method, a keyboard and a key system. By executing the key pressing subprogram of the key in the front edge jitter area, the influence of jitter elimination delay of the front edge jitter area on the time of the key pressing subprogram of the key is avoided, so that the response speed of key execution is improved, and the key execution conforms to an application scene with higher requirements; meanwhile, since the detection of the level change signal of the key detection pin is stopped immediately after the key pressing subprogram of the key is executed in the leading edge jitter area, the jump of the level change signal does not cause the key pressing subprogram to be executed for many times after the key pressing subprogram of the key is executed, and therefore, the embodiment of the invention can avoid the influence caused by the leading edge jitter signal.
Drawings
One or more embodiments are illustrated by way of example in the accompanying drawings, which correspond to the figures in which like reference numerals refer to similar elements and which are not to scale unless otherwise specified.
Fig. 1 is a schematic diagram of module connection of a keyboard according to an embodiment of the present invention;
FIG. 2 is a schematic diagram of a circuit connection of a single-key keyboard with a pull-up trigger circuit according to an embodiment of the present invention;
FIG. 3 is a schematic diagram of a circuit connection of a single-key keyboard with a pull-down trigger circuit according to an embodiment of the present invention;
FIG. 4 is a schematic diagram of a circuit connection of a matrix keyboard according to an embodiment of the present invention;
fig. 5 is a schematic diagram of module connection of a key system according to an embodiment of the present invention;
fig. 6 is a schematic waveform diagram of a level variation signal corresponding to a key press according to an embodiment of the present invention;
FIG. 7 is a flowchart of a method for detecting a key according to an embodiment of the present invention;
FIG. 8 is a flowchart of a method applied to step S13 of the single-key keyboard according to an embodiment of the present invention;
FIG. 9 is a flowchart of a method of step S13 applied to a matrix keyboard according to an embodiment of the present invention;
FIG. 10 is a flowchart of a method for detecting a key according to another embodiment of the present invention;
fig. 11 is a flowchart of a method of step S22 according to an embodiment of the present invention;
FIG. 12 is a flowchart of a method based on the key detection method after step S222 in FIG. 11 according to an embodiment of the present invention;
FIG. 13 is a flowchart of a method based on the key detection method after step S33 in FIG. 12 according to an embodiment of the present invention;
FIG. 14 is a flowchart of a method further included in a key detection method according to another embodiment of the present invention;
fig. 15 is a flowchart of a method of step S52 according to an embodiment of the present invention.
Detailed Description
In order to make the objects, technical solutions and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are some, but not all embodiments of the present invention. All other embodiments, which can be obtained by a person skilled in the art without making any creative effort based on the embodiments in the present invention, belong to the protection scope of the present invention.
In addition, the technical features involved in the embodiments of the present invention described below may be combined with each other as long as they do not conflict with each other.
Referring to fig. 1, fig. 1 is a schematic diagram of module connection of a keyboard according to an embodiment of the present invention. As shown in fig. 1, the keyboard 100 includes a key 10, a key activation circuit 20, and a controller 30.
It is understood that the keyboard 100 is a command and data input device for operating the device, and the keyboard 100 may be fixedly installed on the device or may be connected to the device through a cable. For example, a desktop computer includes a host, a display screen, and an input/output device such as a keyboard 100, and is configured to generate a corresponding instruction and data by clicking a single key 10 or sequentially clicking a plurality of keys 10, the host receives and processes the instruction and data, and sends an operating status to the display screen, and the display screen displays the instruction, the data, and the operating status.
Referring to fig. 2 to 4, the keyboard 100 includes a single-key keyboard and a matrix keyboard.
The keys 10 are distributed on the outer surface of the keyboard 100 according to a certain layout, so that people can input commands and data according to the appointed rules of the keys 10. Specifically, the key 10 triggers an interrupt according to a key pressing subprogram pre-stored in the computer, and executes the key pressing subprogram corresponding to the key 10 when the key 10 is pressed, where the key pressing subprogram is related to an operation to be executed by the key 10. The number of the keys 10 is related to the design requirements and the use requirements of the device, for example, the keyboard 100 of the automatic teller machine generally includes 16 keys 10, including numbers "0-9", number combination "00", character "", control keys "cancel", "correct", "return", and "confirm"; also for example, a desktop computer may have 104 keys in a standard keyboard that is commonly used.
The key trigger circuit 20 includes an input end 21 and an output end 22, the input end 21 of the key trigger circuit 20 is connected to the key 10, and the output end 22 of the key trigger circuit 20 is connected to the controller 30.
The controller 30 comprises at least one key detection pin 31, and the at least one key detection pin 31 is connected to the output terminal 22 of the key triggering circuit 20.
Wherein the controller 30 includes at least one processor and a memory communicatively coupled to the at least one processor. The memory stores instructions executable by the at least one processor to enable the at least one processor to perform a key detection method as disclosed in any one of the following embodiments.
When the keyboard 100 is a single-key keyboard, the key triggering circuit 20 includes a pull-up triggering circuit 201 or a pull-down triggering circuit 202.
As shown in fig. 2, the key 10 includes a key SW1, the pull-up trigger circuit 201 includes a resistor R1, the controller 30 includes an MCU1, and the MCU1 includes a key detection pin 311.
Specifically, one end of the key SW1 is grounded, the other end of the key SW1 is connected with one end of the resistor R1 and the key detection pin 311, and the other end of the resistor R1 is used for receiving a power supply voltage VCC. The key detection pin 311 is set to an input state, which is normally at a high level, and the resistor R1 clamps an uncertain signal at the high level. When the key SW1 is pressed, the electric potential of the key detection pin 311 is pulled low, the level of the key detection pin 311 jumps, and the MCU1 is triggered to execute the key pressing subroutine of the key SW 1.
As shown in fig. 3, the key 10 includes a key SW2, the pull-down trigger circuit 202 includes a resistor R2, the controller 30 includes an MCU2, and the MCU2 includes a key detection pin 312.
Specifically, one end of the key SW2 is used for receiving a power supply voltage VCC, the other end of the key SW2 is connected with one end of the resistor R2 and the key detection pin 312, and the other end of the resistor R2 is grounded. The key detect pin 312 is set to an output state, which is normally low, and the resistor R2 clamps the indeterminate signal at low. When the key SW2 is pressed, the electric potential of the key detection pin 312 is pulled high, the level of the key detection pin 312 jumps, and the MCU2 is triggered to execute the key pressing subroutine of the key SW 2.
When the keyboard 100 is a matrix keyboard, the key triggering circuit 20 includes an and gate and a plurality of pull-up resistors, each of the pull-up resistors is connected to a row pin of a key in the matrix keyboard, the row pins of all keys in the matrix keyboard are connected to the input end of the and gate, the row pins of all keys in the matrix keyboard are connected to the input and output pins of the controller, and the output end of the and gate is connected to the key detection pin of the controller 30.
As shown in fig. 4, the matrix keyboard includes a key 10, a matrix trigger circuit 203, and a controller 30. The keys 10 include a 4 × 4 matrix keyboard composed of keys SW 3-SW 18, the trigger circuit 203 includes four pull-up resistors of a resistor R3, a resistor R4, a resistor R5 and a resistor R6, and an and gate U1, the controller 30 includes an MCU3, and the MCU1 includes a key detection pin 313.
Specifically, column pins of the 4 × 4 matrix keyboard are all connected to one end of the resistor R3, one end of the resistor R4, one end of the resistor R5, one end of the resistor R6, and an input end of the and gate U1, and row pins of the 4 × 4 matrix keyboard are respectively connected to input and output pins (not shown) of the MCU 3; the other end of the resistor R3, the other end of the resistor R4, the other end of the resistor R5 and the other end of the resistor R6 are all used for receiving a power supply voltage VCC; the output end of the and gate U1 is connected to the key detection pin 313.
In this embodiment, the key detection pin 313 is set to low level to trigger interrupt, the column pins of the 4 × 4 matrix keyboard are set to input state and internal pull-up, the row pins of the 4 × 4 matrix keyboard are set to output state, and when a key is pressed, the row pins of the 4 × 4 matrix keyboard output low level.
At present, after the preset time is delayed, the level change signal of the key detection pin is obtained to avoid the influence of the front edge jitter signal on the key detection result. However, for special application scenarios, such as game competitions, even if the delay is of millisecond level, it is sufficient to change the competition result, and eliminating the jitter delay will increase the response time of the key pressing sub-program executed by the key, and decrease the sensitivity of the key.
The keyboard executes the key pressing subprogram of the keys in the front edge jitter area, so that the influence of jitter elimination delay of the front edge jitter area on the time of the keys for executing the key pressing subprogram is avoided, and therefore, the response speed of key execution is improved, and the keyboard accords with an application scene with higher requirements; meanwhile, since the detection of the level change signal of the key detection pin is stopped immediately after the key pressing subprogram of the key is executed in the leading edge jitter area, the jump of the level change signal does not cause the key pressing subprogram to be executed for many times after the key pressing subprogram of the key is executed, and therefore, the embodiment of the invention can avoid the influence caused by the leading edge jitter signal.
Referring to fig. 5, fig. 5 is a schematic diagram of module connection of a key system according to an embodiment of the present invention. As shown in fig. 5, the key system 200 includes a transmission bus 40, a main controller 50, and a plurality of the keyboards 100 as disclosed in any of the above embodiments.
Wherein, the main controller 50 is connected to the transmission bus 40, and each of the keyboards 100 is connected to the transmission bus 40.
It is understood that the keyboard 100 is a basic processing unit of the key system 200, and is used for independently processing key events and uploading key detection and execution results to the main controller 50 through the transmission bus 40, and the main controller 50 is used for storing, managing and controlling the key detection and execution results.
The embodiment of the invention provides a key system, which avoids the influence of the jitter elimination delay of a front edge jitter area on the time for executing the key pressing subprogram by the key by executing the key pressing subprogram of the key in the front edge jitter area, thereby improving the response speed of key execution and enabling the key execution to meet the application scene with higher requirements; meanwhile, since the detection of the level change signal of the key detection pin is stopped immediately after the key pressing subprogram of the key is executed in the leading edge jitter area, the jump of the level change signal does not cause the key pressing subprogram to be executed for many times after the key pressing subprogram of the key is executed, and therefore, the embodiment of the invention can avoid the influence caused by the leading edge jitter signal.
Please refer to fig. 7, which is a flowchart illustrating a method for detecting a key according to an embodiment of the present invention. As shown in fig. 7, the key detection method is applied to a keyboard, and the method includes:
step S11: and when a key event occurs, detecting a level change signal of a key detection pin connected with the key.
It is understood that the key event is used for inputting instructions or data and controlling the operation of the computing device, and the key event is the whole process of one key click, which includes key depression and key release, for example, inputting the letter "J", and then clicking the key "J" is a key event.
When a key event occurs, a level change signal (i.e., a key signal) generated by the key is as shown in fig. 6, and the key detection pin receives the level change signal. Ideally, the level change signal is a rectangular pulse signal, the rising edge and the falling edge are equal to 90 degrees, and if the key detection pin is initialized to be triggered by a high level and a low level, when the key is pressed, the key detection pin is at the low level; if the key detection pin is initialized to be triggered by low level and high level, when the key is pressed down, the key detection pin is at high level. In practical applications, the level-change signal includes a leading-edge jitter area, a stable area, and a trailing-edge jitter area, and when a key is pressed and released or bounced, the key signal has signal interference in the leading-edge jitter area and the trailing-edge jitter area due to mechanical jitter.
Step S12: and when the key detection pin generates level jump for the first time, acquiring a first level of the key detection pin after jumping, wherein the first level is positioned in a leading edge jitter area of the level change signal.
It should be noted that the detection of the level change signal of the key detection pin connected to the key in step S11 is to detect a level jump of the key signal, and ideally, the level jump occurs at the moment when the key is pressed and the key is released, but as shown in fig. 6, the level jump occurs in the leading edge jitter area and the trailing edge jitter area, and the leading edge jitter area and the trailing edge jitter area may fluctuate at least once, which causes the controller to consider that the key signal has a level jump.
Step S13: and executing a key pressing subprogram of the key in the front-edge jitter area according to the level type of the first level and the level type of a preset pressing level, and stopping detecting a level change signal of the key detection pin.
As shown in fig. 6, the first level jump of the key detection pin occurs in the leading edge jitter area, and according to the initialization state of the key detection pin, the preset trigger condition, and the first level of the key detection pin after the first level jump occurs, the current state of the key may be determined, so as to interrupt execution of the key pressing subroutine corresponding to the key.
Furthermore, the key pressing subprogram of the key is executed in the front edge shaking area, and the detection of the level change signal of the key detection pin is stopped, so that the situation that the front edge shaking area has multiple level jumps and the key pressing subprogram is triggered and interrupted for multiple times is avoided.
As shown in fig. 8, when the keyboard includes a single-key keyboard, the executing a key-press sub-routine of the key in the front-edge jitter area according to the level type of the first level and the level type of the preset press level includes:
step S131: and judging whether the level type of the first level is the same as the level type of a preset pressing level.
Step S132: and if so, executing a key pressing subprogram of the key in the front edge shaking area, and stopping detecting the level change signal of the key detection pin.
Step S133: and if not, returning to continuously detect the level change signal of the key detection pin.
In summary, the level jump represents a change of the key state, and the leading edge jitter area and the trailing edge jitter area are also caused by a change of the key state each time, specifically, a mechanical jitter when the key is pressed generates the leading edge jitter area, and a mechanical jitter when the key is released generates the trailing edge jitter area, so that the first level jump occurs in the leading edge jitter area on the key detection pin, and the voltage at the time corresponding to the first level jump is the first level. If the level type of the first level is the same as the level type of the preset pressing level, the button is pressed, and if the level type of the first level is not the same as the level type of the preset pressing level, the button is not pressed, and the next level jump needs to be continuously waited, namely the level change signal of the button detection pin is continuously detected.
As shown in fig. 9, when the keyboard includes a matrix keyboard, the matrix keyboard includes a plurality of rows of pins and columns of pins intersecting with each other, and the executing the key pressing subroutine in the front-edge shaking area according to the level type of the first level and the level type of the preset pressing level includes:
step S134: and judging whether the level type of the first level is the same as the level type of a preset pressing level.
Step S135: and if so, scanning column pins or row pins of all keys in the matrix keyboard.
It should be noted that the controller periodically scans the column pins or the row pins connected to the input/output pins of the controller, and the input/output pins of the controller include, for example, general-purpose input/output (GPIO) pins, wherein the scanning period of the controller should be sufficiently high so that the scanning period is less than the response time of the key.
Step S136: and determining coordinate information of the column pins and the row pins with the changed signals.
In this embodiment, first, by determining whether the level type of the first level is equal to a level type of a preset pressing level, determining coordinate information where a column pin or a row pin where a signal changes, that is, determining that the key is located in a target column or a target row of the matrix keyboard; secondly, by scanning the column pins or the row pins of all keys in the matrix keyboard, the coordinate information where the column pins or the row pins with the changed signals are located is determined, namely the keys are located in the target row or the target column of the matrix keyboard, and therefore the coordinate information where the column pins and the row pins with the changed signals are located is determined.
Step S137: and determining the pressed key according to the coordinate information of the column pins and the row pins with the changed signals.
It can be understood that the column information of the matrix keyboard where the pressed key is located may be determined first, and then the row information of the matrix keyboard where the pressed key is located may be determined, or the row information of the matrix keyboard where the pressed key is located may be determined first, then the column information of the matrix keyboard where the pressed key is located may be determined, and finally the position of the matrix keyboard where the pressed key is located may be determined, that is, the target key of the matrix keyboard may be determined.
For example, when the matrix keyboard is the 4 × 4 matrix keyboard shown in fig. 4, the 4 × 4 matrix keyboard is set to low level to trigger an interrupt, that is, the type of the preset press level is low level, the column pins of the 4 × 4 matrix keyboard are set to an input state and an internal pull-up, and the row pins of the 4 × 4 matrix keyboard are set to an output state.
If the level type of the first level is low level, marking the first level as 'key press', reading the pins of the row by the MCU3, and if the level type of a certain row of pins is low level, determining the row where the target key press is located; setting all column pins of the 4 x 4 matrix keyboard as low levels, setting row pins of the 4 x 4 matrix keyboard as an input state, pulling up the input state, reading the levels of the row pins of the 4 x 4 matrix keyboard in a rapid circulation mode, and determining a row where a target key is located if the level type of a certain row pin of the 4 x 4 matrix keyboard is the low level, thereby determining the position of the target key on the 4 x 4 matrix keyboard.
Step S138: and executing a key pressing subprogram of the key in the front edge shaking area.
When it is determined which key in the matrix keyboard has a key event, the key pressing sub-routine of the key can be executed in the leading edge jitter zone through an interrupt pin.
Step S139: and if not, returning to continuously detect the level change signal of the key detection pin.
And if the level type of the first level is not the same as the level type of the preset pressed level, the key is not pressed, and the key needs to continuously wait for the next level jump, namely the level change signal of the key detection pin is continuously detected.
Referring to fig. 10, the key detection method further includes:
step S21: and after delaying for a first preset time, continuously detecting a level change signal of the key detection pin, and acquiring a second level of the key detection pin at a corresponding moment.
It can be understood that, the key depression sub-routine of the key is executed in the leading edge jitter zone, and the detection of the level change signal of the key detection pin is stopped, the time for stopping the detection is equal to the first preset time length, the first preset time length is used for eliminating the influence of the leading edge jitter signal of the leading edge jitter zone, and therefore, the first preset time length should be longer than the time for which the leading edge jitter zone lasts.
Step S22: and determining the key state of the key according to the level type of the second level and the level type of the preset pressing level.
As shown in fig. 11, the determining the key state of the key according to the level type of the second level and the level type of the preset pressing level includes:
step S221: and judging whether the level type of the second level is the same as the level type of the preset pressing level.
Step S222: and if so, determining that the key state of the key is a key unreleased state.
Step S223: if not, executing a key release subprogram of the key, and stopping detecting the level change signal of the key detection pin.
In summary, in order to determine whether the time for releasing the key-press subprogram is reached after the key-press subprogram is delayed by the first preset time, the determination may be made according to the level type of the second level and the level type of the preset press level.
As shown in fig. 12, after the step S222 of determining that the key state of the key is the key unreleased state, the method further includes:
step S31: and when the key detection pin has level jump again, acquiring a third level of the key detection pin after jumping.
It is understood that the key detect pin again has a level jump in the trailing edge jitter region.
Step S32: and judging whether the level type of the third level is the same as the level type of a preset release level.
Step S33: and if so, executing a key release subprogram of the key, and stopping detecting the key detection pin.
And after the key state of the key is determined to be the key unreleased state, if the level type of the third level is the same as the level type of the preset release level, indicating that the time for executing the key pressing subprogram is reached, and triggering and executing the key releasing subprogram of the key.
Step S34: and if not, returning to continuously detect the level change signal of the key detection pin.
As shown in fig. 13, the key states include a key released state, and after executing the key release subroutine of the key at step S33, the method further includes:
step S41: and after delaying the second preset time, continuously detecting the level change signal of the key detection pin, and acquiring a fourth level of the key detection pin at the corresponding moment.
It can be understood that after executing the key release subroutine, the detection of the key detection pin is stopped, and the stop time is equal to the second preset time period, where the second preset time period is used to eliminate the influence of the trailing edge shaking signal of the trailing edge shaking area, and therefore, the second preset time period should be longer than the duration of the trailing edge shaking area.
In this embodiment, the key detection method includes delaying the first preset time and delaying the second preset time. In some embodiments, the key detection method includes delaying the first preset time period, or the key detection method includes delaying the second preset time period.
Step S42: and judging whether the level type of the fourth level is the same as the level type of the preset release level.
Step S43: and if so, determining that the key state of the key is the key released state.
Step S44: and if not, returning to continuously detect the level change signal of the key detection pin.
It should be noted that, all the "detecting the level change signal of the key detection pin" described in the foregoing embodiments is to detect whether the key detection pin has a level jump, and determine whether a level type corresponding to the level jump is the same as the level type of the preset press level or the preset release level based on the level jump.
In this embodiment, when the preset pressing level is a low level, the preset releasing level is a high level, and when the preset pressing level is a high level, the preset releasing level is a low level.
Referring to fig. 14, a method flowchart of a key detection method according to another embodiment of the present invention is further shown. As shown in fig. 14, the key detection method further includes:
step S51: and counting the pressing times of the keys.
Step S52: and adjusting the first preset time length and/or the second preset time length according to the number of times of pressing the key.
The shaking time can be increased along with the increase of the pressing times of the key after metal in the key is fatigued, and the first preset time and/or the second preset time can be dynamically adjusted according to the pressing times of the key, so that the key detection method adapts to the change of the key. For example, when the number of times of pressing the key reaches 50 ten thousand, the first preset duration and the second preset duration are adjusted to 10ms, when the number of times of pressing the key reaches 100 ten thousand, the first preset duration and the second preset duration are adjusted to 12ms, and when the number of times of pressing the key reaches 200 ten thousand, the first preset duration and the second preset duration are adjusted to 14ms.
As shown in fig. 15, the adjusting the first preset time period or the second preset time period according to the number of times of pressing the key includes:
step S521: and judging whether the pressing times of the key is greater than a preset time threshold value or not.
Step S522: if yes, prolonging the first preset time and/or the second preset time.
Step S523: if not, keeping the first preset time length and/or the second preset time length.
The preset time threshold value can be set according to the metal characteristic and the structural characteristic of the key. In some embodiments, after the first preset duration and/or the second preset duration are/is extended, the number of times of pressing the key is cleared, the statistics on the number of times of pressing the key is returned to be continued, and when the number of times of pressing the key is greater than a preset number threshold again, the first preset duration and the second preset duration are both increased by a preset increment time, for example, the preset increment time may be set to 2ms, 3ms, 4ms, or the like.
The embodiment of the invention provides a key detection method, which detects a level change signal of a key detection pin connected with a key when a key event occurs; when the key detection pin generates level jump for the first time, acquiring a first level of the key detection pin after the jump, wherein the first level is positioned in a leading edge jitter area of a level change signal; according to the level type of the first level and the level type of the preset pressing level, executing the key pressing subprogram of the key in the front edge jitter area, thereby avoiding the influence of jitter elimination delay of the front edge jitter area on the time of executing the key pressing subprogram by the key, and therefore, the embodiment of the invention improves the response speed of key execution and enables the key execution to meet the application scene with higher requirements; meanwhile, the key pressing subprogram of the key is executed in the front edge jitter area, and the detection of the level change signal of the key detection pin is stopped, so that after the key pressing subprogram of the key is executed, the jump of the level change signal does not cause the key pressing subprogram to be executed for multiple times, and therefore, the embodiment of the invention can avoid the influence caused by the front edge jitter signal.
Finally, it should be noted that: the above examples are only intended to illustrate the technical solution of the present invention, but not to limit it; within the idea of the invention, also technical features in the above embodiments or in different embodiments may be combined, steps may be implemented in any order, and there are many other variations of the different aspects of the invention as described above, which are not provided in detail for the sake of brevity; although the present invention has been described in detail with reference to the foregoing embodiments, it will be understood by those of ordinary skill in the art that: the technical solutions described in the foregoing embodiments may still be modified, or some technical features may be equivalently replaced; and these modifications or substitutions do not depart from the spirit of the corresponding technical solutions of the embodiments of the present invention.

Claims (12)

1. A key detection method is applied to a keyboard, and is characterized in that key states comprise key unreleased states, and the method comprises the following steps:
when a key event occurs, detecting a level change signal of a key detection pin connected with the key;
when the key detection pin generates level jump for the first time, acquiring a first level of the key detection pin after jumping, wherein the first level is located in a leading edge jitter area of the level change signal;
executing a key pressing subprogram of the key in the leading edge jitter area according to the level type of the first level and the level type of a preset pressing level, and stopping detecting a level change signal of the key detection pin, wherein if the level type of the first level is different from the level type of the preset pressing level, the level change signal of the key detection pin is returned to be detected;
after delaying for a first preset time, continuously detecting a level change signal of the key detection pin, and acquiring a second level of the key detection pin at a corresponding moment;
judging whether the level type of the second level is the same as the level type of the preset pressing level;
if so, determining that the key state of the key is a key unreleased state;
if not, executing a key release subprogram of the key, and stopping detecting the level change signal of the key detection pin.
2. The method of claim 1, wherein after determining that the key state of the key is a key unreleased state, the method further comprises:
when the key detection pin has level jump again, acquiring a third level of the key detection pin after jumping;
judging whether the level type of the third level is the same as the level type of a preset release level;
if yes, executing a key release subprogram of the key, and stopping detecting the key detection pin;
and if not, returning to continuously detect the level change signal of the key detection pin.
3. The method of claim 2, wherein the key state comprises a key released state;
after executing the key release subroutine of the key, the method further comprises:
after delaying for a second preset time, continuously detecting a level change signal of the key detection pin, and acquiring a fourth level of the key detection pin at a corresponding moment;
judging whether the level type of the fourth level is the same as the level type of the preset release level;
if yes, determining the key state of the key to be a key released state;
and if not, returning to continuously detect the level change signal of the key detection pin.
4. The method of claim 3,
when the preset pressing level is a low level, the preset release level is a high level;
and when the preset pressing level is a high level, the preset release level is a low level.
5. The method of claim 3, further comprising:
counting the pressing times of the keys;
and adjusting the first preset time length and/or the second preset time length according to the number of times of pressing the key.
6. The method of claim 5, wherein the adjusting the first preset duration or the second preset duration according to the number of times the key is pressed comprises:
judging whether the pressing times of the key are larger than a preset time threshold value or not;
if so, prolonging the first preset time and/or the second preset time;
if not, keeping the first preset time length and/or the second preset time length.
7. The method of any of claims 1-6, wherein the keyboard comprises a single-key keyboard;
the executing a key pressing subprogram of the key in the leading edge jitter area according to the level type of the first level and the level type of a preset pressing level comprises:
judging whether the level type of the first level is the same as the level type of a preset pressing level;
and if so, executing a key pressing subprogram of the key in the front edge jitter area, and stopping detecting the level change signal of the key detection pin.
8. The method of any of claims 1 to 6, wherein the keyboard comprises a matrix keyboard comprising a number of columns and rows of pins intersecting each other;
the executing a key pressing subprogram of the key in the leading edge jitter area according to the level type of the first level and the level type of a preset pressing level comprises:
judging whether the level type of the first level is the same as the level type of a preset pressing level;
if yes, scanning column pins or row pins of all keys in the matrix keyboard;
determining coordinate information of the column pins and the row pins with changed signals;
determining a pressed key according to the coordinate information of the column pins and the row pins with the changed signals;
and executing a key pressing subprogram of the key in the front edge shaking area.
9. A keyboard, comprising:
pressing a key;
the key trigger circuit comprises an input end and an output end, and the input end of the key trigger circuit is connected with the key;
the controller comprises at least one key detection pin, and the at least one key detection pin is connected with the output end of the key trigger circuit;
wherein the controller includes:
at least one processor; and the number of the first and second groups,
a memory communicatively coupled to the at least one processor; wherein the content of the first and second substances,
the memory stores instructions executable by the at least one processor to enable the at least one processor to perform the method of key detection of any one of claims 1 to 8.
10. The keyboard of claim 9,
the keyboard comprises a single-key keyboard;
the key trigger circuit is a pull-up trigger circuit or a pull-down trigger circuit.
11. The keyboard of claim 9,
the keyboard comprises a matrix keyboard;
the key trigger circuit comprises an AND gate and a plurality of pull-up resistors, each pull-up resistor is connected with a column pin of a key in the matrix keyboard, the column pins of all the keys in the matrix keyboard are connected to the input end of the AND gate, the row pins of all the keys in the matrix keyboard are connected to the input and output pins of the controller, and the output end of the AND gate is connected with the key detection pin of the controller.
12. A key system, comprising:
a transmission bus;
the main controller is connected with the transmission bus;
a number of keyboards as claimed in any one of claims 9 to 11, each of which is connected to the transmission bus.
CN201910453021.1A 2019-05-28 2019-05-28 Key detection method, keyboard and key system Active CN110221709B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201910453021.1A CN110221709B (en) 2019-05-28 2019-05-28 Key detection method, keyboard and key system

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201910453021.1A CN110221709B (en) 2019-05-28 2019-05-28 Key detection method, keyboard and key system

Publications (2)

Publication Number Publication Date
CN110221709A CN110221709A (en) 2019-09-10
CN110221709B true CN110221709B (en) 2023-01-06

Family

ID=67818401

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201910453021.1A Active CN110221709B (en) 2019-05-28 2019-05-28 Key detection method, keyboard and key system

Country Status (1)

Country Link
CN (1) CN110221709B (en)

Families Citing this family (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110716135A (en) * 2019-10-28 2020-01-21 中国兵器工业集团第二一四研究所苏州研发中心 Effective capturing circuit and capturing method for impact type mechanical switch signal
CN111552589B (en) * 2020-05-09 2023-06-09 中国航空无线电电子研究所 Key jamming detection and function maintenance method and management framework for full keyboard
CN112073046A (en) * 2020-07-22 2020-12-11 深圳市优必选科技股份有限公司 Detection method and detection device for key triggering event and terminal
CN114544153A (en) * 2020-11-24 2022-05-27 京东方科技集团股份有限公司 Detection method and detection circuit for key board and rotary encoder, and display device
CN112487739A (en) * 2020-12-15 2021-03-12 安徽皖通邮电股份有限公司 Signal jitter elimination method and system based on EPLD
CN113422610B (en) * 2021-06-18 2023-09-05 河南翔宇医疗设备股份有限公司 Key detection method, device, equipment and storage medium
CN114448444A (en) * 2022-01-21 2022-05-06 长沙锐逸微电子有限公司 High-performance mechanical keyboard driving chip and mechanical keyboard
CN115389856B (en) * 2022-10-27 2023-01-06 季华实验室 Signal change edge detection method and device, electronic equipment and storage medium
CN116302265B (en) * 2023-03-14 2024-01-23 南京莱斯信息技术股份有限公司 Method and equipment for realizing display screen interface switching based on state machine and semaphore

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US4194188A (en) * 1977-09-26 1980-03-18 Redactron Corporation Interrogation of key switches using pulse width detection
CN107562456A (en) * 2017-08-24 2018-01-09 歌尔科技有限公司 Key configurations method, button operation method, device and electronic equipment

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US4194188A (en) * 1977-09-26 1980-03-18 Redactron Corporation Interrogation of key switches using pulse width detection
CN107562456A (en) * 2017-08-24 2018-01-09 歌尔科技有限公司 Key configurations method, button operation method, device and electronic equipment

Non-Patent Citations (2)

* Cited by examiner, † Cited by third party
Title
一种实时性强并且可移植的按键消抖方法;胡传志等;《单片机与嵌入式系统应用》;20150701(第07期);全文 *
基于FPGA控制的按键模块的设计与实现;李莉;《山西电子技术》;20190415(第02期);全文 *

Also Published As

Publication number Publication date
CN110221709A (en) 2019-09-10

Similar Documents

Publication Publication Date Title
CN110221709B (en) Key detection method, keyboard and key system
KR920002755B1 (en) Apparatus for mode changes method and apparatus for cursor control
CN106547395B (en) Touch key, anti-misoperation control method and device for touch key and terminal
US9158423B2 (en) Method of detecting presence of interference source, and touch sensing system
TWI592845B (en) Method and associated controller for adaptively adjusting touch-control threshold
US7218250B2 (en) Method and apparatus for keyboard control with programmable debounce and jog
CN112817483B (en) Multi-point touch processing method, device, equipment and storage medium
US9176595B2 (en) Speed adjustable USB keyboard
EP0097816B1 (en) Automatically adjusted delay function for timed repeat character capability of a keyboard
WO2021036718A1 (en) Touch point determining method and device
EP3698235B1 (en) User input devices and methods for identifying a user input in a user input device
US20220381827A1 (en) Keyboard with wire aging self-adaptation, self-adaptation method for keyboard, electronic computing device readable medium with stored program, and electronic computing device program product
US9696793B2 (en) Systems and methods for selectably suppressing computing input events triggered by variable pressure and variable displacement sensors
CN111124519A (en) Method and system for optimizing starting speed of android application program based on input response
US11526228B1 (en) Method for monitoring an operation condition of an interactive information system
US20210208689A1 (en) Proximity detection method and proximity detection keyboard
CN107340872B (en) Key system and control method thereof
TWI459273B (en) A touch screen device with correction function and its correction method
CN112073046A (en) Detection method and detection device for key triggering event and terminal
CN107305442B (en) Input device and control method thereof
WO2006109349A1 (en) Information processing device, information processing method, program, and computer-readable recording medium
CN106293304B (en) Interface operation method and device
GB2352153A (en) Pointer memory for improved selection accuracy
US20190369745A1 (en) Method for Operating an Active Input Element and Corresponding Input Element, Input Arrangement and Computer Program Product
US11290126B2 (en) Key scanning method, scan method for key scan circuit, and input device implemented therewith

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant