C#で現在指定キーが押されているか判別する方法。
using System.Runtime.InteropServices; public class Hogehoge { [DllImport("user32")] static extern short GetAsyncKeyState(Keys vKey); public Hogehoge() { // コンストラクタ } public void IsPressCtrlKey() { if( GetAsyncKeyState( Keys.ControlKey ) < 0 ) { // コントロールキーが押されている場合の処理 } } }
こんな感じ。APIなのでVBとかVCでもいけると思うデス。詳細はメソッド名でググればわさわさ出てくるハズ。
ていうか別にコンストラクタまで書かんでもいいやん自分…(苦笑)。