@@ -363,6 +363,9 @@ static ConsoleKeyInfo CtrlAlt(char c)
363
363
public static ConsoleKeyInfo CtrlAltRBracket = CtrlAlt ( ']' ) ;
364
364
public static ConsoleKeyInfo CtrlAltQuestion = CtrlAlt ( '?' ) ;
365
365
366
+ public static ConsoleKeyInfo VolumeUp = Key ( ConsoleKey . VolumeUp ) ;
367
+ public static ConsoleKeyInfo VolumeDown = Key ( ConsoleKey . VolumeDown ) ;
368
+ public static ConsoleKeyInfo VolumeMute = Key ( ConsoleKey . VolumeMute ) ;
366
369
367
370
[ DllImport ( "user32.dll" ) ]
368
371
public static extern int VkKeyScan ( short wAsciiVal ) ;
@@ -469,6 +472,9 @@ internal static bool IgnoreKeyChar(this ConsoleKeyInfo key)
469
472
case ConsoleKey . RightArrow :
470
473
case ConsoleKey . Tab :
471
474
case ConsoleKey . UpArrow :
475
+ case ConsoleKey . VolumeUp :
476
+ case ConsoleKey . VolumeDown :
477
+ case ConsoleKey . VolumeMute :
472
478
return true ;
473
479
}
474
480
@@ -560,43 +566,6 @@ internal static int GetNormalizedHashCode(this ConsoleKeyInfo obj)
560
566
return unchecked ( ( ( h1 << 5 ) + h1 ) ^ h2 ) ;
561
567
}
562
568
563
- internal static bool ShouldInsert ( this ConsoleKeyInfo key )
564
- {
565
- var keyChar = key . KeyChar ;
566
- if ( keyChar == '\0 ' ) return false ;
567
- foreach ( char c in " `~!@#$%^&*()-_=+[{]}\\ |;:'\" ,<.>/?" ) {
568
- // we always want to insert chars essential to the PowerShell experience
569
- if ( keyChar == c ) { return true ; }
570
- }
571
- if ( key . Modifiers != 0 )
572
- {
573
- // We want to ignore control sequences - but distinguishing a control sequence
574
- // isn't as simple as it could be because we will get inconsistent modifiers
575
- // depending on the OS or keyboard layout.
576
- //
577
- // Windows will give us the key state even if we didn't care, e.g. it's normal
578
- // to see Alt+Control (AltGr) on a Spanish, French, or German keyboard for many normal
579
- // characters. So we just ask the OS what mods to expect for a given key.
580
- // On non-Windows - anything but Shift is assumed to be a control sequence.
581
- ConsoleModifiers expectedMods = default ( ConsoleModifiers ) ;
582
- if ( RuntimeInformation . IsOSPlatform ( OSPlatform . Windows ) )
583
- {
584
- var keyWithMods = WindowsKeyScan ( key . KeyChar ) ;
585
- if ( keyWithMods . HasValue )
586
- {
587
- expectedMods = keyWithMods . Value . Modifiers ;
588
- }
589
- }
590
- else
591
- {
592
- expectedMods = key . Modifiers & ConsoleModifiers . Shift ;
593
- }
594
- return key . Modifiers == expectedMods ;
595
- }
596
-
597
- return true ;
598
- }
599
-
600
569
internal static bool IsUnmodifiedChar ( this ConsoleKeyInfo key , char c )
601
570
{
602
571
return key . KeyChar == c &&
0 commit comments