• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

dapplo / Dapplo.Windows / 36697195522

30 Sep 2026 09:36AM UTC coverage: 41.48% (+8.9%) from 32.555%
36697195522

push

github

web-flow
Merge pull request #56 from dapplo/release/3.0

Claude review and fixes for Greenshot, this is huge..

1288 of 3206 branches covered (40.17%)

Branch coverage included in aggregate %.

1458 of 3179 new or added lines in 148 files covered. (45.86%)

290 existing lines in 44 files now uncovered.

2894 of 6876 relevant lines covered (42.09%)

52.25 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

89.8
/src/Dapplo.Windows.Input/Keyboard/VirtualKeyCodeExtensions.cs
1
// Copyright (c) Dapplo and contributors. All rights reserved.
2
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
3
using Dapplo.Windows.Input.Enums;
4

5
namespace Dapplo.Windows.Input.Keyboard;
6

7
/// <summary>
8
/// Extensions for VirtualKeyCode
9
/// </summary>
10
public static class VirtualKeyCodeExtensions
11
{
12
    /// <summary>
13
    /// Test if the VirtualKeyCode is a modifier key: Shift, Control, Alt (Menu) or Windows, left, right or generic.
14
    /// The lock/toggle keys (CapsLock, NumLock, ScrollLock) are not modifiers, see <see cref="IsToggleKey"/>.
15
    /// </summary>
16
    /// <param name="virtualKeyCode">VirtualKeyCode</param>
17
    /// <returns>bool</returns>
18
    public static bool IsModifier(this VirtualKeyCode virtualKeyCode)
19
    {
20
        bool isModifier = false;
52 ✔
21
        switch (virtualKeyCode)
22
        {
23
            case VirtualKeyCode.LeftShift:
24
            case VirtualKeyCode.Shift:
25
            case VirtualKeyCode.RightShift:
26
            case VirtualKeyCode.Control:
27
            case VirtualKeyCode.LeftControl:
28
            case VirtualKeyCode.RightControl:
29
            case VirtualKeyCode.Menu:
30
            case VirtualKeyCode.LeftMenu:
31
            case VirtualKeyCode.RightMenu:
32
            case VirtualKeyCode.LeftWin:
33
            case VirtualKeyCode.RightWin:
34
            case VirtualKeyCode.Win:
35
                isModifier = true;
34 ✔
36
                break;
37
        }
38

39
        return isModifier;
52 ✔
40
    }
41

42
    /// <summary>
43
    /// Test if the VirtualKeyCode is a toggle/lock key (CapsLock, NumLock, ScrollLock)
44
    /// </summary>
45
    /// <param name="virtualKeyCode">VirtualKeyCode</param>
46
    /// <returns>bool</returns>
47
    public static bool IsToggleKey(this VirtualKeyCode virtualKeyCode)
48
    {
49
        return virtualKeyCode is VirtualKeyCode.Capital or VirtualKeyCode.NumLock or VirtualKeyCode.Scroll;
24 ✔
50
    }
51

52
    /// <summary>
53
    /// Test if the VirtualKeyCode is a generic key, which stands for its left and right variant: Shift, Control, Menu (Alt) or the pseudo code Win.
54
    /// </summary>
55
    /// <param name="virtualKeyCode">VirtualKeyCode</param>
56
    /// <returns>bool</returns>
57
    public static bool IsGeneric(this VirtualKeyCode virtualKeyCode)
58
    {
59
        return virtualKeyCode is VirtualKeyCode.Shift or VirtualKeyCode.Control or VirtualKeyCode.Menu or VirtualKeyCode.Win;
1 !
60
    }
61

62
    /// <summary>
63
    /// Test if the specified key matches the expected key, a generic expected key (Shift, Control, Menu or Win) matches its left and right variant.
64
    /// </summary>
65
    /// <param name="virtualKeyCode">VirtualKeyCode, the key which was pressed</param>
66
    /// <param name="expected">VirtualKeyCode, the key which is expected</param>
67
    /// <returns>bool true if the key matches</returns>
68
    public static bool Matches(this VirtualKeyCode virtualKeyCode, VirtualKeyCode expected)
69
    {
70
        if (virtualKeyCode == expected)
370 ✔
71
        {
72
            return true;
132 ✔
73
        }
74

75
        return expected switch
238 !
76
        {
238 ✔
77
            VirtualKeyCode.Shift => virtualKeyCode is VirtualKeyCode.LeftShift or VirtualKeyCode.RightShift,
39 ✔
78
            VirtualKeyCode.Control => virtualKeyCode is VirtualKeyCode.LeftControl or VirtualKeyCode.RightControl,
144 !
NEW
79
            VirtualKeyCode.Menu => virtualKeyCode is VirtualKeyCode.LeftMenu or VirtualKeyCode.RightMenu,
✔
80
            VirtualKeyCode.Win => virtualKeyCode is VirtualKeyCode.LeftWin or VirtualKeyCode.RightWin,
14 ✔
81
            _ => false
41 ✔
82
        };
238 ✔
83
    }
84
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE TRIAL · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc