CN114637409A - Key operation detection method, detection device, electronic device and storage medium - Google Patents

Key operation detection method, detection device, electronic device and storage medium Download PDF

Info

Publication number
CN114637409A
CN114637409A CN202210248290.6A CN202210248290A CN114637409A CN 114637409 A CN114637409 A CN 114637409A CN 202210248290 A CN202210248290 A CN 202210248290A CN 114637409 A CN114637409 A CN 114637409A
Authority
CN
China
Prior art keywords
key
key information
sequence
information
operation detection
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.)
Pending
Application number
CN202210248290.6A
Other languages
Chinese (zh)
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.)
Xi'an Goltech Electronic Technology Co ltd
Original Assignee
Xi'an Goltech Electronic 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 Xi'an Goltech Electronic Technology Co ltd filed Critical Xi'an Goltech Electronic Technology Co ltd
Priority to CN202210248290.6A priority Critical patent/CN114637409A/en
Publication of CN114637409A publication Critical patent/CN114637409A/en
Pending legal-status Critical Current

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
    • 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/0227Cooperation and interconnection of the input arrangement with other functional units of a computer

Landscapes

  • Engineering & Computer Science (AREA)
  • General Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Human Computer Interaction (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Input From Keyboards Or The Like (AREA)

Abstract

The invention discloses a key operation detection method, a key operation detection device, electronic equipment and a computer readable storage medium. Wherein, the method comprises the following steps: detecting key events, and sequentially storing key information corresponding to each detected key event according to a first sequence, wherein the first sequence is the sequence of detecting each key event; and sequentially reading the key information according to a second sequence, and determining key operation according to the sequentially read key information, wherein the second sequence is the sequence for storing each piece of key information. The invention aims to improve the accuracy of key operation identification of a user on electronic equipment.

Description

Key operation detection method, detection device, electronic device and storage medium
Technical Field
The present invention relates to the field of electronic devices, and in particular, to a key operation detection method, a key operation detection apparatus, an electronic device, and a computer-readable storage medium.
Background
With the development of economic technology, electronic devices are more and more widely used. Most electronic devices require keys to obtain commands input by users during operation. At present, the key detection mode generally identifies the pressed and released levels of different key interfaces through a key interrupt processing function, then distinguishes whether the key is pressed for a long time or pressed for a short time through a timer, and completes the key jitter elimination function through time delay. In this way, under the condition of more keys, the operation logic is complex, and the reading of the level information corresponding to different key events is easy to be blocked, so that the key events are missed or the key events are identified by mistake, and the key operation of the user cannot be accurately identified.
Disclosure of Invention
The invention mainly aims to provide a key operation detection method, a key operation detection device, electronic equipment and a computer readable storage medium, and aims to improve the accuracy of key operation identification of a user on the electronic equipment.
In order to achieve the above object, the present invention provides a key operation detection method, including the following steps:
detecting key events, and sequentially storing key information corresponding to each detected key event according to a first sequence, wherein the first sequence is the sequence of detecting each key event;
and sequentially reading the key information according to a second sequence, and determining key operation according to the sequentially read key information, wherein the second sequence is the sequence for storing each piece of key information.
Optionally, the step of detecting a key event and sequentially storing the key information corresponding to each detected key event according to the first sequence includes:
detecting key events, and sequentially writing key information corresponding to each detected key event into a first-in first-out queue according to the first sequence;
the step of reading the key information in sequence according to the second sequence comprises the following steps:
and sequentially reading each piece of key information according to the writing sequence of each piece of key information in the first-in first-out queue.
Optionally, the step of sequentially reading each piece of key information according to the writing sequence of each piece of key information in the fifo queue includes:
acquiring a first quantity of key information currently written in the first-in first-out queue;
reading target key information and updating a second quantity of currently read key information in the first-in first-out queue; the target key information is key information with the most front arrangement order in the key information which is not read currently in the first-in first-out queue;
if the second number is smaller than the first number, determining new target key information according to the writing sequence, returning to execute the step of reading the target key information, and updating the second number of the currently read key information in the first-in first-out queue;
and if the second quantity is the first quantity, ending reading the key information in the first-in first-out queue.
Optionally, the key operation detection method further includes:
executing the step of detecting the key event and starting timing to obtain a first timing duration;
when the first timing duration is less than or equal to a first preset clock period, executing the step of sequentially writing the key information corresponding to each detected key event into a first-in first-out queue according to the first sequence;
and when the first timing duration is longer than the first preset clock period, executing the step of sequentially reading each piece of key information according to the writing sequence of each piece of key information in the first-in first-out queue.
Optionally, after the step of detecting a key event and starting timing to obtain a first timing duration, the method further includes:
when the first timing duration is longer than the first preset clock period, starting timing to obtain a second timing duration;
when the second timing duration is less than or equal to a second preset clock period, executing the step of sequentially reading each piece of key information according to the writing sequence of each piece of key information in the first-in first-out queue;
and when the second timing duration is longer than the second preset clock period, returning to the step of executing the detection key event and starting timing to obtain the first timing duration.
Optionally, the key information corresponding to the key event includes a key identifier, a key event type, and a time when the corresponding key event is detected.
Optionally, any two pieces of successively read key information are defined as first key information and second key information in sequence, and the step of determining the key operation according to the successively read key information includes:
when the first key information and the second key information meet a preset condition, determining a time difference value between second time and first time; the preset conditions include that the first key information and the second key information both include the same target key identification, the key event type in the first key information is that a key is pressed, and the key event type in the second key information is that a key is released, the first time is the time for detecting the corresponding key event included in the first key information, and the second time is the time for detecting the corresponding key event included in the second key information;
when the time difference is smaller than or equal to a set threshold value, determining that the key operation is a short-press operation of a key corresponding to the target key identification;
and when the time difference is larger than the set threshold, determining that the key operation is a long-press operation of the key corresponding to the target key identification.
In addition, in order to achieve the above object, the present application also proposes a key operation detection device including: the key operation detection method comprises a memory, a processor and a key operation detection program stored on the memory and capable of running on the processor, wherein the key operation detection program realizes the steps of the key operation detection method according to any one of the above items when being executed by the processor.
In addition, in order to achieve the above object, the present application also proposes an electronic apparatus including:
the key module comprises at least two keys;
the key operation detection device as described above, wherein the at least two keys are both connected with the key operation detection device.
Further, in order to achieve the above object, the present application also proposes a computer readable storage medium having a key operation detection program stored thereon, which when executed by a processor implements the steps of the key operation detection method as described in any one of the above.
According to the key operation detection method, in the process of detecting the key time, the key information corresponding to each key time is stored in sequence according to the detection sequence of each key event, the stored key information is further read in sequence according to the storage sequence of each key information, and the single-time operation is determined according to the sequentially read key information.
Drawings
FIG. 1 is a diagram illustrating a hardware configuration involved in the operation of an embodiment of the electronic device according to the present invention;
FIG. 2 is a schematic flow chart illustrating a key operation detection method according to an embodiment of the present invention;
FIG. 3 is a schematic flow chart illustrating a key operation detection method according to another embodiment of the present invention;
FIG. 4 is a schematic flowchart illustrating a key operation detection method according to another embodiment of the present invention;
FIG. 5 is a schematic diagram illustrating a process of writing and reading key information in a FIFO queue according to an embodiment of the key operation detection method of the present invention;
fig. 6 is a flowchart illustrating a key operation detection method according to still another embodiment of the present invention.
The implementation, functional features and advantages of the present invention will be further described with reference to the accompanying drawings.
Detailed Description
It should be understood that the specific embodiments described herein are merely illustrative of the invention and are not intended to limit the invention.
The main solution of the embodiment of the invention is as follows: detecting key events, and sequentially storing key information corresponding to each detected key event according to a first sequence, wherein the first sequence is the sequence of detecting each key event; and sequentially reading the key information according to a second sequence, and determining key operation according to the sequentially read key information, wherein the second sequence is the sequence for storing each piece of key information.
In the prior art, the key detection mode generally identifies the pressed and released high and low levels of different key interfaces through a key interrupt processing function, then distinguishes whether the key is pressed for a long time or pressed for a short time through a timer, and completes the key jitter elimination function through time delay. In this way, under the condition of more keys, the operation logic is complex, and the reading of the level information corresponding to different key events is easy to be blocked, so that the key events are missed or the key events are identified by mistake, and the key operation of the user cannot be accurately identified.
The invention provides the solution, and aims to improve the accuracy of key operation identification of a user on the electronic equipment.
The embodiment of the invention provides a key operation detection device 1 which can be applied to detecting key operations on electronic equipment. Here, the electronic device may be any electronic device provided with a button, such as a smart watch, a smart bracelet, a head-mounted display device, a smart headset and other smart wearable devices, a smart sound box, a mobile phone, a robot and the like. In this embodiment, the key specifically refers to a physical key. In other embodiments, the keys may also be virtual keys.
The key operation detection device 1 may be a device connected to an electronic apparatus, or may be a device built in the electronic apparatus.
In an embodiment of the present invention, referring to fig. 1, a key operation detection device 1 includes: a processor 1001 (e.g., a CPU), a memory 1002, a timer 1003, and the like. The components in the key operation detection device are connected through a communication bus. The memory 1002 may be a high-speed RAM memory or a non-volatile memory (e.g., a disk memory). The memory 1002 may alternatively be a storage device separate from the processor 1001.
In this embodiment, the timer 1003 is a tick timer.
Those skilled in the art will appreciate that the configuration of the device shown in fig. 1 is not intended to be limiting of the device and may include more or fewer components than those shown, or some components may be combined, or a different arrangement of components.
As shown in fig. 1, a key operation detection program may be included in the memory 1002, which is a computer-readable storage medium. In the apparatus shown in fig. 1, the processor 1001 may be configured to call a key operation detection program stored in the memory 1002 and perform operations of relevant steps of the key operation detection method in the following embodiments.
Further, an embodiment of the present invention further provides an electronic device, where the electronic device may be any electronic device provided with a key 2, such as an intelligent wearable device such as an intelligent watch, an intelligent bracelet, a head-mounted display device, an intelligent headset, an intelligent sound box, a mobile phone, a robot, and the like.
It should be noted that, in this embodiment, the electronic device is a device installed with an embedded system.
Referring to fig. 1, the electronic device includes at least two keys 2 and the key operation detection device 1, where the at least two keys 2 are connected to the key operation detection device 1. In this embodiment, the key 2 specifically refers to a physical key. In other embodiments, key 2 may also be a virtual key. The key operation detection device 1 can detect the key operation of at least two keys 2 according to the key operation detection method mentioned in any of the following embodiments.
The embodiment of the invention also provides a key operation detection method which is applied to the key operation detection device and is used for detecting the key operation executed by the user on the electronic equipment. It should be noted that the key operation detection method according to the embodiment of the present invention is mainly directed to key operation detection of an electronic device having at least two keys. In other embodiments, the key operation detection method according to the embodiments of the present invention may also be applied to key operation detection of an electronic device having one key.
Referring to fig. 2, an embodiment of a key operation detection method according to the present application is provided. In this embodiment, the key operation detection method includes:
step S10, detecting key events, and sequentially storing key information corresponding to each detected key event according to a first sequence, wherein the first sequence is the sequence of detecting each key event;
the key event is specifically an action event generated when a key is triggered by a key operation of a user. The key event specifically includes a key being pressed and a key being released.
After the electronic equipment is powered on or the electronic equipment runs a preset mode, detecting a key signal output by each key in real time, and determining a key event generated by each key according to the key signal.
And when a key event is detected, determining and storing key information corresponding to the key event, wherein the key information corresponding to the detected key event is stored at a preset position firstly, and the key information corresponding to the detected key event is stored at the preset position secondly. The preset position is specifically a preset storage area for storing key information to be identified.
In the process of storing the key information of each detected key event according to the first sequence, if the key events of different keys are detected at the same time, the key information corresponding to the key event detected at the same moment can be stored in sequence according to the corresponding preset sequence among the keys, and then the step of storing the key information of each detected key event according to the first sequence is returned; if the key events of different keys are not detected simultaneously, the step of storing the key information of each detected key event according to the first sequence can be maintained. The preset sequence can be a default configuration sequence of the system or a set sequence according to the operation habit of the user.
The key information is specifically information related to key events and used for key operation identification. Each key event has a corresponding key information. The key information corresponding to different key events is different. In this embodiment, the key information corresponding to the key event includes a key identifier, a key event type, and a time when the corresponding key event is detected. The key identifier is a unique identifier for distinguishing a corresponding key from other keys, and may be a key name or a key number. The key event types specifically include a first type indicating that the corresponding key is pressed and a second type indicating that the corresponding key is released. The time when the key event is detected is specifically the time when the key event occurs. In other embodiments, the key information may include a control code corresponding to the key event, such as a control code of a pressed key 1, b of released key 2, and the like, in addition to the key identifier, the key event type, and the time when the corresponding key event is detected.
And step S20, sequentially reading each piece of key information according to a second sequence, and determining key operation according to the sequentially read key information, wherein the second sequence is the sequence for storing each piece of key information.
The key operation is specifically an operation performed by a user on a key to input a target instruction to the electronic device.
Specifically, in the process executed in step S10, the timing may be started every time a key event is detected, and step S20 may be executed when the timing duration is greater than the set duration and the next key event is not detected. Or, the timing may be started when the detection of the key event is started, and the step S20 may be executed when the timing duration reaches the preset period. Alternatively, in the process of step S10, the number of pieces of key information already stored is counted, and step S20 is executed when the number of pieces of key information is greater than the set number. The set number is less than or equal to the maximum number of key information allowed to be stored in the preset position.
Specifically, the key information stored first is read first, and then the key information stored later is read. Specifically, successively read key information is analyzed according to the identification rule of the key operation, and the operation corresponding to the read key information is obtained. The key operation may be one or more than one, and when the key operation is more than one, the key operation may include a key operation corresponding to a different key or more than one key operation corresponding to the same key.
According to the key operation detection method provided by the embodiment of the invention, in the process of detecting the key time, the key information corresponding to each key time is sequentially stored according to the detection sequence of each key event, the stored key information is further sequentially read according to the storage sequence of each key event, and single-time operation is determined according to the sequentially read key information.
Further, based on the above embodiments, another embodiment of the key operation detection method of the present application is provided. In this embodiment, referring to fig. 3, the step S10 includes:
step S11, detecting key events, and writing the key information corresponding to each detected key event into a first-in first-out queue in sequence according to the first sequence;
based on step S11, step S20 includes:
step S21, sequentially reading each piece of key information according to the writing order of each piece of key information in the fifo queue.
The fifo queue is specifically a data structure that performs data insertion and deletion on the basis of fifo. The fifo queue may specifically determine the maximum number of storage elements allowed for the electronic device according to the number of keys on the electronic device.
The key information corresponding to each detected key event can be written into the tail of the queue as a new element, and the ranking of the key information corresponding to the detected key event in the queue is prior to the ranking of the key information corresponding to the detected key event in the queue.
When the key information is read, the key information is read from the queue in sequence according to the order of the bits arranged in the queue.
In this embodiment, the first-in first-out queue is used for storing and reading the key information, so as to further ensure the orderliness and accuracy of key information detection in the key operation identification process, and further improve the accuracy of key operation identification of a user on the electronic device. And the first-in first-out queue is used for storing and reading the key information, the key information can be read in a non-blocking mode, and the key information can be read without waiting for the completion of the key dithering filtering processing, so that the orderliness and the accuracy of key information detection are further improved, and the accuracy of key operation identification of a user is further improved.
Further, in this embodiment, the key operation detection method further includes: executing the step of detecting the key event and starting timing to obtain a first timing duration; when the first timing duration is less than or equal to a first preset clock period, executing the step of sequentially writing the key information corresponding to each detected key event into a first-in first-out queue according to the first sequence; and when the first timing duration is longer than the first preset clock period, executing the step of sequentially reading each piece of key information according to the writing sequence of each piece of key information in the first-in first-out queue.
The first preset clock period may be specifically determined according to preset types of all allowed key operations of the electronic device, the number of keys on the electronic device, and/or the maximum number of allowed storage elements of the fifo queue, and the like. Different key operation types, different numbers of keys and/or different maximum allowable storage numbers correspond to different first preset clock cycles.
And continuously detecting the key events when the first timing duration does not reach a first preset clock period, sequentially writing the key information of the detected key events into the first-in first-out queue according to the detected sequence, and sequentially reading the key information according to the writing sequence when the first timing duration exceeds the first preset clock period.
The key information can be deleted from the head of the first-in first-out queue every time the reading of the key information is finished, so that the element quantity stored in the first-in first-out queue can not exceed the maximum allowable quantity; or deleting the key information in the first-in first-out queue after finishing reading all the information in the first-in first-out queue. In addition, in the process of reading the key information, the key event can be kept and detected, the key information of the newly detected key event is written into the tail of the first-in first-out queue, and if the number of the key information currently written into the first-in first-out queue reaches the allowed maximum number, the head of the current first-in first-out queue can be used as the new tail of the queue.
In this embodiment, the trigger time for starting reading the key information is limited by the first preset clock period, which is beneficial to further ensuring that the storage and writing processes of the key information are not blocked, so as to further improve the accuracy of key operation identification of a user on the electronic device. Moreover, the reading of the key information can be regularly executed in the tick timer, and the detection in the main program is not needed all the time, which is beneficial to reducing the resource consumption of the embedded system.
Further, in this embodiment, after the step of executing the step of detecting the key event and starting timing to obtain the first timing duration, the method further includes: when the first timing duration is longer than the first preset clock period, starting timing to obtain a second timing duration; when the second timing duration is less than or equal to a second preset clock cycle, executing the step of sequentially reading each piece of key information according to the writing sequence of each piece of key information in the first-in first-out queue; and when the second timing duration is longer than the second preset clock cycle, returning to the step of executing the key event detection and starting timing to obtain the first timing duration.
The second preset clock period may be specifically determined according to the first preset clock period, the preset types of all allowed key operations of the electronic device, the number of keys on the electronic device, and/or the maximum number of allowed storage elements in the fifo queue. The different first preset clock cycles, the key operation types, the different key numbers and/or the different maximum allowable storage numbers correspond to different second preset clock cycles.
And continuously reading the key information in the first-in first-out queue according to a second sequence when the second timing duration does not reach a second preset clock cycle, and re-detecting the key event when the second timing duration exceeds the second preset clock cycle.
In this embodiment, the second preset clock period is used to limit the key information reading duration and trigger the time for detecting the next key operation, so as to further ensure that the storage and writing processes of the key information are not blocked, and different key operations of the user can be accurately distinguished, so as to further improve the accuracy of key operation identification of the user on the electronic device. Moreover, the reading and writing of the key information can be periodically executed in the tick timer, and the detection in the main program is not needed all the time, which is beneficial to reducing the resource consumption of the embedded system.
Further, based on any of the above embodiments, a further embodiment of the key operation detection method of the present application is provided. In this embodiment, referring to fig. 4, the step S21 includes:
step S211, acquiring a first quantity of key information currently written in the first-in first-out queue;
specifically, the preset identification value is used for representing the number of the key information currently written in the first-in first-out queue. The initial value of the identification value is 0, the numerical value of the identification value is increased by 1 every time one piece of key information is written in the first-in first-out queue, and the numerical value of the identification value is decreased by 1 every time one piece of key information is deleted from the first-in first-out queue.
Based on this, reading the current identification value may obtain the first number here.
Step S212, reading the target key information, and updating a second quantity of currently read key information in the first-in first-out queue; the target key information is key information with the most front arrangement order in the key information which is not read currently in the first-in first-out queue;
the second number is updated once each time one key information in the FIFO queue is read. Specifically, the information in the first-in first-out queue is read before and after the information is read, and the updated second number is obtained after the current second number is increased by 1.
Step S213, if the second quantity is smaller than the first quantity, determining new target key information according to the writing sequence, returning to execute the step of reading the target key information, and updating the second quantity of the currently read key information in the first-in first-out queue;
specifically, the key information arranged one bit after the current bit in the fifo queue is used as new target key information, and then the new target key information is read and the second amount is further updated.
Step S214, if the second number is the first number, ending reading the key information in the fifo queue.
After step S214, the key operation may be determined according to all currently read key information.
Further, after step S214, the step of detecting key events and sequentially storing the key information corresponding to each detected key event according to the first sequence may be returned. Further, after step S214, the step of detecting the key event and starting to count the time to obtain the first counted time length may be returned to.
In order to better understand the technical solution designed in this embodiment, the following description is given by taking five fifo queues as an example with reference to fig. 5:
the Write variable indicates the Write position and the Read variable indicates the Read position. In the initial state, as shown in fig. 5(a), Read is 0, and null in the fifo queue indicates that there is no written key information. If the keys K1 and K2 are pressed in sequence, the key information of the events of K1 pressing, K1 bouncing, K2 pressing, and K2 bouncing are sequentially stored in the fifo queue, and the data in the fifo queue becomes (b) of fig. 5. Wherein, K1, K2 are characterized by key identification, Up is characterized by key being released, Down is characterized by key being pressed.
Every time one key information is Read from the first-in first-out queue, 1 is added to Read, and the Wrie variable is unchanged; and every time one piece of key information is stored in the first-in first-out queue, Read is unchanged, and the Write variable is added with 1. If a key information is Read from the fifo queue in fig. 5(b), Read becomes 1 and Write remains 4; when three key events continue to be Read from the FIFO queue, Read becomes 4 and Write remains 4. At this time, the two variables are equal, which means that all key events are processed, no new key event is processed, and at this time, the key event can be continuously detected until new key information is written into the first-in first-out queue.
In this embodiment, through the above manner, it can be ensured that the key information corresponding to all key times is not missed in the key operation identification process, thereby further improving the accuracy of key operation identification.
Further, based on any of the above embodiments, a further embodiment of the key operation detection method of the present application is provided. In this embodiment, any two pieces of successively read key information are defined as first key information and second key information in sequence, with reference to fig. 6, step S30 includes:
step S31, when the first key information and the second key information meet the preset condition, determining a time difference value between the second time and the first time; the preset conditions include that the first key information and the second key information both include the same target key identification, the key event type in the first key information is that a key is pressed, and the key event type in the second key information is that a key is released, the first time is the time for detecting the corresponding key event included in the first key information, and the second time is the time for detecting the corresponding key event included in the second key information;
step S32, when the time difference is smaller than or equal to a set threshold, determining that the key operation is a short-press operation of the key corresponding to the target key identification;
step S33, when the time difference is greater than the set threshold, determining that the key operation is a long-press operation of the key corresponding to the target key identifier.
For example, there are 4 pieces of key information read, which are K1 Down T1, K1 Up T2, K2 Down T3, and K2 Up T4, where K1 and K2 denote key identifiers, Up denotes a key released key event, Down denotes a key event in which a key is pressed, and T1, T2, T3, and T4 denote occurrence times corresponding to the key events, respectively. Based on the above, the key identifications of the first key information and the second key information are both K1, and the first key information detected firstly contains the information that the key is pressed, and the second key information detected later contains the information that the key is released, so that the key operation of the K1 key can be a long press or a short press according to the comparison of T2-T1 and the set threshold value; the key identifications of the third key information and the fourth key information are both K2, and the first detected third key information contains information that the key is pressed, and the second detected fourth key information contains information that the key is released, so that the key operation of the K2 key can be a long press or a short press according to the comparison of the T4-T3 and the set threshold value.
In the embodiment, by the mode, the long-press operation and the short-press operation of different keys can be accurately distinguished, so that the accuracy of key operation identification of different key durations on the electronic equipment is guaranteed to be improved.
In addition, an embodiment of the present invention further provides a computer-readable storage medium, where a key operation detection program is stored on the computer-readable storage medium, and when the key operation detection program is executed by a processor, the relevant steps of any embodiment of the above key operation detection method are implemented.
It should be noted that, in this document, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or system that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or system. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other like elements in a process, method, article, or system that comprises the element.
The above-mentioned serial numbers of the embodiments of the present invention are only for description, and do not represent the advantages and disadvantages of the embodiments.
Through the above description of the embodiments, those skilled in the art will clearly understand that the method of the above embodiments can be implemented by software plus a necessary general hardware platform, and certainly can also be implemented by hardware, but in many cases, the former is a better implementation manner. Based on such understanding, the technical solutions of the present invention may be embodied in the form of a software product, which is stored in a storage medium (e.g., ROM/RAM, magnetic disk, optical disk) as described above and includes instructions for enabling a terminal device (e.g., a mobile phone, a computer, a server, an electronic device, or a network device) to execute the method according to the embodiments of the present invention.
The above description is only a preferred embodiment of the present invention, and is not intended to limit the scope of the present invention, and all equivalent structures or equivalent processes performed by the present invention or directly or indirectly applied to other related technical fields are also included in the scope of the present invention.

Claims (10)

1. A key operation detection method is characterized by comprising the following steps:
detecting key events, and sequentially storing key information corresponding to each detected key event according to a first sequence, wherein the first sequence is the sequence of detecting each key event;
and sequentially reading the key information according to a second sequence, and determining key operation according to the sequentially read key information, wherein the second sequence is the sequence for storing each piece of key information.
2. The key operation detection method of claim 1, wherein the step of detecting key events and sequentially storing the key information corresponding to each detected key event according to a first sequence comprises:
detecting key events, and sequentially writing key information corresponding to each detected key event into a first-in first-out queue according to the first sequence;
the step of sequentially reading the key information according to the second sequence comprises the following steps:
and sequentially reading each piece of key information according to the writing sequence of each piece of key information in the first-in first-out queue.
3. The method according to claim 2, wherein the step of sequentially reading each piece of key information according to the writing order of each piece of key information in the fifo queue comprises:
acquiring a first quantity of key information currently written in the first-in first-out queue;
reading target key information and updating a second quantity of currently read key information in the first-in first-out queue; the target key information is key information with the most front arrangement order in the key information which is not read currently in the first-in first-out queue;
if the second number is smaller than the first number, determining new target key information according to the writing sequence, returning to execute the step of reading the target key information, and updating the second number of the currently read key information in the first-in first-out queue;
and if the second quantity is the first quantity, ending reading the key information in the first-in first-out queue.
4. A key operation detection method according to claim 2, wherein the key operation detection method further comprises:
executing the step of detecting the key event and starting timing to obtain a first timing duration;
when the first timing duration is less than or equal to a first preset clock period, executing the step of sequentially writing the key information corresponding to each detected key event into a first-in first-out queue according to the first sequence;
and when the first timing duration is longer than the first preset clock period, executing the step of sequentially reading each piece of key information according to the writing sequence of each piece of key information in the first-in first-out queue.
5. The key operation detecting method of claim 4, wherein after the step of detecting a key event and starting to count for a first counted duration, further comprising:
when the first timing duration is longer than the first preset clock period, starting timing to obtain a second timing duration;
when the second timing duration is less than or equal to a second preset clock period, executing the step of sequentially reading each piece of key information according to the writing sequence of each piece of key information in the first-in first-out queue;
and when the second timing duration is longer than the second preset clock period, returning to the step of executing the detection key event and starting timing to obtain the first timing duration.
6. A key operation detection method according to any one of claims 1 to 5, wherein the key information corresponding to the key event includes a key identification, a key event type, and a time at which the corresponding key event was detected.
7. The key operation detection method according to claim 6, wherein any two successively read key information are defined as first key information and second key information in turn, and the step of determining key operation according to the successively read key information includes:
when the first key information and the second key information meet a preset condition, determining a time difference value between second time and first time; the preset conditions include that the first key information and the second key information both include the same target key identification, the key event type in the first key information is that a key is pressed, and the key event type in the second key information is that a key is released, the first time is the time for detecting the corresponding key event included in the first key information, and the second time is the time for detecting the corresponding key event included in the second key information;
when the time difference is smaller than or equal to a set threshold value, determining that the key operation is a short-press operation of a key corresponding to the target key identification;
and when the time difference is larger than the set threshold, determining that the key operation is a long-press operation of the key corresponding to the target key identification.
8. A key operation detection device, characterized by comprising: a memory, a processor and a key operation detection program stored on the memory and executable on the processor, the key operation detection program when executed by the processor implementing the steps of the key operation detection method according to any one of claims 1 to 7.
9. An electronic device, characterized in that the electronic device comprises:
the key module comprises at least two keys;
the key operation detection device of claim 8, wherein the at least two keys are each connected to the key operation detection device.
10. A computer-readable storage medium, having a key operation detection program stored thereon, which, when executed by a processor, implements the steps of the key operation detection method according to any one of claims 1 to 7.
CN202210248290.6A 2022-03-14 2022-03-14 Key operation detection method, detection device, electronic device and storage medium Pending CN114637409A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202210248290.6A CN114637409A (en) 2022-03-14 2022-03-14 Key operation detection method, detection device, electronic device and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202210248290.6A CN114637409A (en) 2022-03-14 2022-03-14 Key operation detection method, detection device, electronic device and storage medium

Publications (1)

Publication Number Publication Date
CN114637409A true CN114637409A (en) 2022-06-17

Family

ID=81947796

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202210248290.6A Pending CN114637409A (en) 2022-03-14 2022-03-14 Key operation detection method, detection device, electronic device and storage medium

Country Status (1)

Country Link
CN (1) CN114637409A (en)

Similar Documents

Publication Publication Date Title
CN110806923B (en) Parallel processing method and device for block chain tasks, electronic equipment and medium
CN112817483B (en) Multi-point touch processing method, device, equipment and storage medium
CN112199170A (en) Timing processing method, device and equipment of real-time operating system and storage medium
CN105549825A (en) Position adjustment method for application icon and user terminal
CN109656416B (en) Control method and device based on multimedia data and related equipment
CN110851297A (en) Method, device, system and medium for processing interface jitter state
CN111078418B (en) Operation synchronization method, device, electronic equipment and computer readable storage medium
CN113923519A (en) Video rendering method and device, computer equipment and storage medium
CN114637409A (en) Key operation detection method, detection device, electronic device and storage medium
WO2024119930A1 (en) Scheduling method and apparatus, and computer device and storage medium
US11256549B2 (en) Method and apparatus for thread scheduling
CN111831413A (en) Thread scheduling method and device, storage medium and electronic equipment
CN112840309B (en) Command scheduling method, device and storage medium
CN107015491B (en) A kind of sequence control method
Quinton et al. Formal analysis of sporadic bursts in real-time systems
CN110456978B (en) Touch control method, system, terminal and medium for touch terminal
WO2019062412A1 (en) Method and apparatus for recording application information, storage medium, and electronic device
CN111143351B (en) IMSI data management method and equipment
JP3603752B2 (en) Display with control function
CN113114268A (en) Key identification method, device, equipment and storage medium
CN112988105A (en) Playing state control method and device, electronic equipment and storage medium
CN115629678B (en) Touch information processing method, device, equipment and storage medium
CN106293304B (en) Interface operation method and device
CN109614148B (en) Data logic operation method, monitoring method and device
CN112805978A (en) Enhanced anchor protocol for event stream processing

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