たるきちのあれこれ









  Topプログラミングサンプル ▶ 修飾子キーの取得

修飾子キーを取得するサンプルです。

C#

// Shiftキーが押されている場合
if ((Control.ModifierKeys & Keys.Shift) == Keys.Shift)
{
    // 処理
}

// Ctrlキーが押されている場合
if ((Control.ModifierKeys & Keys.Control) == Keys.Control)
{
    // 処理
}

// Altキーが押されている場合
if ((Control.ModifierKeys & Keys.Alt) == Keys.Alt)
{
    // 処理
}