簡體   English   中英

如何在Mac上使用C#檢測空格鍵是否已鍵入/按下?

[英]How do I detect if the spaced bar is typed/Pressed using C# on mac?

我正在編寫一個程序,如果按下空格鍵,它將執行某些操作。 我到目前為止:

  Console.WriteLine("Listening for the BIG BUTTON:......... ");
  ConsoleKeyInfo name = Console.ReadKey();
  Console.WriteLine("You pressed {0}", name.KeyChar);

  if(//keyPressed is the spacekey" ){

    Console.WriteLine("Space key is pressed);
  }

https://msdn.microsoft.com/zh-CN/library/system.consolekey(v=vs.110).aspx

Console.WriteLine("Listening for the BIG BUTTON:......... ");
ConsoleKeyInfo name = Console.ReadKey();
Console.WriteLine("You pressed {0}", name.KeyChar);

if(name.Key == ConsoleKey.Spacebar )
{
    Console.WriteLine("Space key was pressed");
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM