Method, system, medium and product for avoiding shortcut conflicts in operating system
Patent Information
- Application Number
- CN202511314341.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-09-15
- Publication Date
- 2026-09-29
- Estimated Expiration
- 2045-09-15
AI Technical Summary
当系统既抓取Super_L或Super_R、又抓取Super+D键时,如果用户按下Super+D键,按照正常处理流程,则会同时激活两个快捷键,引起快捷键重复响应
[0014]和现有技术相比,本发明主要可起到下述有益效果:本发明操作系统中避免快捷键冲突的方法包括为目标按键初始化设置阻止触发标记为真;在收到快捷键按下事件时,若快捷键按下事件为目标按键的单个按键事件,则将阻止触发标记置为假,否则将阻止触发标记置为真并触发快捷键按下事件中对应的目标按键和其他普通按键的组合快捷键行为;在收到快捷键弹起事件时,若快捷键弹起事件为目标按键的单个按键事件且阻止触发标记为假,则触发目标按键的单个按键行为,本发明通过阻止触发标记,结合快捷键按下事件、快捷键弹起事件两者的组合处理,能够克服Linux操作系统下包括Super键在内的各类物理按键的单键和组合键的快捷键冲突导致时激活两个快捷键、引起快捷键重复响应的问题,提升Linux操作系统下的快捷键使用体验和灵活度。
Smart Images

Figure CN121143906B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of operating system technology, and specifically to a method, system, medium, and product for avoiding shortcut key conflicts in an operating system. Background Technology
[0002] In the graphical environment of the Linux operating system, the system provides a shortcut key setting function. The system captures shortcut keys to ensure that only the system can receive the shortcut key combination. For example, the operating system generally triggers the display and hiding of the Start Menu window by capturing the Super key release event. The Super key may have different names, such as Super key (Linux system), Win key (Windows system), Start key, Command key (Mac system), etc. Currently, the Linux operating system is still mainly based on the X Windows window system (Xorg). In the X Windows window system, XGrabKey is generally used to capture keyboard keys. XGrabKey input includes modifier keys and normal keys. Modifier keys include Ctrl, Shift, Alt, Super, etc., and normal keys include the 26 letters and special characters, such as "A", "B", "=", etc. A shortcut key consists of one, more, or any modifier keys (including zero) + one normal key or any normal key (including zero), such as Super+D, Ctrl+Alt+A, AnyModifier+B, Ctrl+AnyKey. The physical key corresponding to Super is special; this physical key can be used as both a modifier key and a normal key. When used as a modifier key, its corresponding keycode is Super; when used as a regular key, the keycode is Super_L or Super_R. However, if the operating system's shortcut keys include both Super and Super + other regular keys, it can lead to shortcut key conflicts or duplicate shortcut key responses. For example... Figure 1 As shown, when a system process captures the shortcut key combination Super + any other key, it can correctly receive the Super physical key press and release events. However, it will also receive the Super + other ordinary key press and release events simultaneously. If a non-system process needs to capture Super + other ordinary keys (e.g., Super + D) at this time, capturing Super + D will fail, affecting the functionality of the non-system process. Figure 2As shown, to avoid shortcut key capture conflicts, for a single Super key, it should be captured using Super_L or Super_R. This ensures that non-system processes can correctly capture the Super + normal key shortcut. When the system captures both Super_L or Super_R and Super + D, if the user presses Super + D, according to the normal processing flow, both shortcuts will be activated simultaneously, causing duplicate shortcut responses. Therefore, resolving the shortcut key conflict between the single Super key and Super combination keys in the Linux operating system has become a critical technical problem that urgently needs to be solved. Summary of the Invention
[0003] The technical problem to be solved by this invention is to provide a method, system, medium, and product for avoiding shortcut key conflicts in an operating system, addressing the aforementioned problems of the prior art. This invention aims to overcome the problem of shortcut key conflicts between single and combination keys of various physical keys, including the Super key, in the Linux operating system, which leads to the activation of two shortcut keys and causing repeated shortcut key responses, thereby improving the user experience and flexibility of shortcut keys in the Linux operating system.
[0004] To solve the above-mentioned technical problems, the technical solution adopted by the present invention is as follows: A method for avoiding shortcut key conflicts in an operating system includes the following steps: S101, initialize the target button and set the trigger prevention flag to true; S102, when a shortcut key press event is received, if the shortcut key press event is a single key event of the target key, the trigger prevention flag is set to false; otherwise, the trigger prevention flag is set to true and the combined shortcut key behavior of the target key and other ordinary keys in the shortcut key press event is triggered; when a shortcut key release event is received, if the shortcut key release event is a single key event of the target key and the trigger prevention flag is false, the single key behavior of the target key is triggered.
[0005] Optionally, when triggering a single key action of the target key in step S102, the trigger prevention flag is also set to true.
[0006] Optionally, steps S101 and S102 are execution steps in the target program, and step S101 is the execution step when the target program is executed.
[0007] Optionally, the target key in step S101 is the Super key.
[0008] Optionally, the single key event of the target key in step S102 refers to the Super_L event or Super_R event of the Super key.
[0009] Optionally, step S102 includes: S201, monitor shortcut key press events or shortcut key release events. If a shortcut key press event or shortcut key release event is received, proceed to step S202. S202, determine whether the received shortcut key press event is true. If true, proceed to step S203; otherwise, if the received shortcut key release event is true, proceed to step S206. S203, determine whether the shortcut key press event is the Super_L event or the Super_R event of the Super key. If it is the Super_L event or the Super_R event of the Super key, then jump to step S204. S204, set the trigger prevention flag to false, and jump to step S201; S205, set the prevent trigger flag to true, trigger the shortcut key combination behavior of the target key and other ordinary keys in the shortcut key press event, and jump to step S201; S206, determine whether the shortcut key release event is the Super_L event or Super_R event of the Super key and whether the trigger prevention flag is false. If true, set the trigger prevention flag to true and trigger the single Super key key press behavior of the target key, then jump to step S201.
[0010] Optionally, the combined shortcut key behavior of the target key and other ordinary keys in the trigger shortcut key press event refers to the behavior of displaying the desktop by triggering the Super key and the D key, and the single key behavior of triggering the target key refers to the behavior of displaying or hiding the start menu window by triggering a single Super key.
[0011] Furthermore, the present invention also provides a system for avoiding shortcut key conflicts in an operating system, comprising a microprocessor and a memory interconnected thereto, wherein the microprocessor is programmed or configured to execute a method for avoiding shortcut key conflicts in the operating system.
[0012] Furthermore, the present invention also provides a computer-readable storage medium storing a computer program or instructions that are programmed or configured to execute, via a processor, a method for avoiding shortcut key conflicts in the operating system.
[0013] In addition, the present invention also provides a computer program product, including a computer program or instructions that are programmed or configured to execute, via a processor, a method for avoiding shortcut key conflicts in the operating system.
[0014] Compared with existing technologies, the present invention mainly achieves the following beneficial effects: The method for avoiding shortcut key conflicts in the operating system of the present invention includes setting the prevent trigger flag to true for the target key during initialization; when a shortcut key press event is received, if the shortcut key press event is a single key event of the target key, the prevent trigger flag is set to false; otherwise, the prevent trigger flag is set to true and the combined shortcut key behavior of the target key and other ordinary keys in the shortcut key press event is triggered; when a shortcut key release event is received, if the shortcut key release event is a single key event of the target key and the prevent trigger flag is false, the single key behavior of the target key is triggered. By preventing the trigger flag and combining the combined processing of shortcut key press events and shortcut key release events, the present invention can overcome the problem of simultaneous activation of two shortcut keys and repeated shortcut key responses caused by shortcut key conflicts of single keys and combination keys of various physical keys, including the Super key, under the Linux operating system, thereby improving the shortcut key user experience and flexibility under the Linux operating system. Attached Figure Description
[0015] Figure 1 This is a schematic diagram illustrating a scenario where capturing the Super+D shortcut key fails in existing technologies.
[0016] Figure 2 This is a schematic diagram illustrating a scenario where capturing the Super+D shortcut key via Super_L / R fails in existing technologies.
[0017] Figure 3 This is a schematic diagram of the basic process of the method in an embodiment of the present invention.
[0018] Figure 4 This is a detailed flowchart illustrating the method of an embodiment of the present invention. Detailed Implementation
[0019] To enable those skilled in the art to better understand the technical solutions of the present invention, the technical solutions of the present invention will be further described in detail below with reference to the accompanying drawings in the embodiments of the present invention.
[0020] like Figure 3 As shown, the method for avoiding shortcut key conflicts in the operating system of this embodiment includes the following steps: S101, initialize the target button and set the trigger prevention flag to true; S102, when a shortcut key press event is received, if the shortcut key press event is a single key event of the target key, the trigger prevention flag is set to false; otherwise, the trigger prevention flag is set to true and the combined shortcut key behavior of the target key and other ordinary keys in the shortcut key press event is triggered; when a shortcut key release event is received, if the shortcut key release event is a single key event of the target key and the trigger prevention flag is false, the single key behavior of the target key is triggered.
[0021] In step S102 of this embodiment, when triggering a single key action of the target key, the trigger prevention flag is also set to true.
[0022] In this embodiment, steps S101 and S102 are executed in the target program, and step S101 is the execution step when the target program is running.
[0023] In this embodiment, the target key in step S101 is the Super key, so the trigger prevention flag is named block_super_triggered. In step S101, the trigger prevention flag block_super_triggered is set to true for initialization. It should be noted that the method in this embodiment can be applied to the shortcut key conflict problem of single keys and combination keys of modifier keys such as Ctrl, Shift, Alt, and Super. By solving the shortcut key conflict problem of single keys and combination keys of modifier keys, the richness of shortcut keys in the system is greatly expanded.
[0024] In this embodiment, the single key event of the target key in step S102 refers to the Super_L event or Super_R event of the Super key.
[0025] like Figure 4 As shown, step S102 in this embodiment includes: S201, monitor shortcut key press events or shortcut key release events. If a shortcut key press event or shortcut key release event is received, proceed to step S202. S202, determine whether the received shortcut key press event is true. If true, proceed to step S203; otherwise, if the received shortcut key release event is true, proceed to step S206. S203, determine whether the shortcut key press event is the Super_L event or the Super_R event of the Super key. If it is the Super_L event or the Super_R event of the Super key, then jump to step S204. S204, set the trigger prevention flag block_super_triggered to false, and jump to step S201; S205, set the block_super_triggered flag to true, trigger the shortcut key combination behavior of the target key and other ordinary keys in the shortcut key press event, and jump to step S201; S206, determine whether the shortcut key release event is the Super_L event or Super_R event of the Super key and whether the blocking trigger flag block_super_triggered is false. If true, set the blocking trigger flag block_super_triggered to true and trigger the single Super key key action of the target key, then jump to step S201.
[0026] In Linux systems, the Super key is typically used to show or hide the Start Menu window. There are many common Super key combinations, and these combinations vary depending on the desktop environment. For example, Super+D shows the desktop. Taking the conflict between the single Super+D shortcut and its combination as an example, the combined shortcut of the target key and other ordinary keys triggering the Super and D keys to show the desktop refers to the single Super key press.
[0027] Assume the system is configured with both Super_L and Super+D shortcut keys. Super_L corresponds to showing / hiding the Start menu window, and Super+D shows the desktop; a terminal window is already open on the desktop. The steps to verify the method in this embodiment include: 1) Pressing and releasing the Super physical key. Upon release, the shortcut key release event successfully triggers the behavior of showing the Start menu window. 2) Pressing and releasing the Super physical key again. Upon release, the shortcut key release event successfully triggers the behavior of hiding the Start menu window. 3) Pressing both the Super and D physical keys simultaneously, the shortcut key press event successfully triggers the behavior of showing the desktop, all desktop windows are hidden, and the behavior of showing the Start menu window is not triggered.
[0028] In summary, the method of this embodiment includes initializing the target key by setting the prevent trigger flag to true; when a shortcut key press event is received, if the shortcut key press event is a single key event of the target key, the prevent trigger flag is set to false; otherwise, the prevent trigger flag is set to true and the combined shortcut key behavior of the target key and other ordinary keys in the shortcut key press event is triggered; when a shortcut key release event is received, if the shortcut key release event is a single key event of the target key and the prevent trigger flag is false, the single key behavior of the target key is triggered. This embodiment, by preventing the trigger flag and combining the processing of both shortcut key press and shortcut key release events, can overcome the problem of shortcut key conflicts between single and combination keys of various physical keys, including the Super key, under the Linux operating system, which leads to the activation of two shortcut keys and causes repeated shortcut key responses, thus improving the shortcut key user experience and flexibility under the Linux operating system.
[0029] Furthermore, this embodiment also provides a system for avoiding shortcut key conflicts in an operating system, including a microprocessor and a memory interconnected, wherein the microprocessor is programmed or configured to execute a method for avoiding shortcut key conflicts in the operating system.
[0030] Furthermore, this embodiment also provides a computer-readable storage medium storing a computer program or instructions that are programmed or configured to execute, via a processor, a method for avoiding shortcut key conflicts in the operating system.
[0031] Furthermore, this embodiment also provides a computer program product, including a computer program or instructions that are programmed or configured to execute, via a processor, a method for avoiding shortcut key conflicts in the operating system.
[0032] Those skilled in the art will understand that the technical solutions provided by this invention may take the form of a method, system, or computer program product. Therefore, this invention may take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, this invention may take the form of a computer program product embodied on one or more computer-readable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code. This invention is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the invention. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, produce an implementation of the flowchart... Figure 1 One or more processes and / or boxes Figure 1 The computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The functions specified in one or more boxes. These computer program instructions may also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable apparatus for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.
[0033] The above description is merely a preferred embodiment of the present invention. The scope of protection of the present invention is not limited to the above embodiments. All technical solutions falling within the scope of the present invention's concept are within the scope of protection of the present invention. It should be noted that for those skilled in the art, any improvements and modifications made without departing from the principles of the present invention should also be considered within the scope of protection of the present invention.
Claims
1. A method for avoiding shortcut key conflicts in an operating system, characterized in that, Includes the following steps: S101, initialize the target button and set the trigger prevention flag to true; S102, when a shortcut key press event is received, if the shortcut key press event is a single key event of the target key, the trigger prevention flag is set to false; otherwise, the trigger prevention flag is set to true and the combined shortcut key behavior of the target key and other ordinary keys in the shortcut key press event is triggered; when a shortcut key release event is received, if the shortcut key release event is a single key event of the target key and the trigger prevention flag is false, the single key behavior of the target key is triggered. The target key in step S101 is the Super key; the single key event of the target key in step S102 refers to the Super_L event or Super_R event of the Super key, and step S102 includes: S201, monitor shortcut key press events or shortcut key release events. If a shortcut key press event or shortcut key release event is received, proceed to step S202. S202, determine whether the received shortcut key press event is true. If true, proceed to step S203; otherwise, if the received shortcut key release event is true, proceed to step S206. S203, determine whether the shortcut key press event is the Super_L event or the Super_R event of the Super key. If it is the Super_L event or the Super_R event of the Super key, then jump to step S204. S204, set the trigger prevention flag to false, and jump to step S201; S205, set the prevent trigger flag to true, trigger the shortcut key combination behavior of the target key and other ordinary keys in the shortcut key press event, and jump to step S201; S206, determine whether the shortcut key release event is the Super_L event or Super_R event of the Super key and whether the trigger prevention flag is false. If true, set the trigger prevention flag to true and trigger the single Super key key press behavior of the target key, then jump to step S201.
2. The method for avoiding shortcut key conflicts in an operating system according to claim 1, characterized in that, When triggering a single key action of the target key in step S102, the trigger prevention flag is also set to true.
3. The method for avoiding shortcut key conflicts in an operating system according to claim 1, characterized in that, Steps S101 and S102 are executed in the target program, and step S101 is the execution step when the target program is executed.
4. The method for avoiding shortcut key conflicts in an operating system according to claim 1, characterized in that, The combined shortcut key behavior of the target key and other ordinary keys in the trigger shortcut key press event refers to the behavior of triggering the Super key and D key to display the desktop, and the single key behavior of triggering the target key refers to the behavior of triggering the single Super key to display or hide the Start Menu window.
5. A system for avoiding shortcut key conflicts in an operating system, comprising a microprocessor and a memory interconnected, characterized in that, The microprocessor is programmed or configured to perform a method for avoiding shortcut key conflicts in the operating system of any one of claims 1 to 4.
6. A computer-readable storage medium storing a computer program or instructions, characterized in that, The computer program or instructions are programmed or configured to execute, via a processor, a method for avoiding shortcut key conflicts in the operating system described in any one of claims 1 to 4.
7. A computer program product, comprising a computer program or instructions, characterized in that, The computer program or instructions are programmed or configured to execute, via a processor, a method for avoiding shortcut key conflicts in the operating system described in any one of claims 1 to 4.