Visual Studio | WPF > 마우스 왼쪽 클릭 + Shift (또는 Alt 키) 감지 > Keyboard.IsKeyDown | Key.LeftShift | Key.LeftAlt
6937 단어 myVisualStudioStudyWPF키보드
Windows 8.1 Pro (64bit)
Microsoft Visual Studio 2017 Community
Sublime Text 2
처리 개요
버튼을 누를 때 Shift 또는 Alt 키를 감지합니다.
참고
프로젝트 설정
Visual Studio / WPF > Windows 응용 프로그램에서 System.Console.WriteLine()을 콘솔에 출력
code
MainWindow.xaml
<Window x:Class="_171110_t1439_shiftKey.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:_171110_t1439_shiftKey"
mc:Ignorable="d"
Title="MainWindow" Height="350" Width="525">
<Grid>
<Button Width="120" Height="30" Content="Return fire!" Click="Button_Click"/>
</Grid>
</Window>
MainWindow.xaml.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace _171110_t1439_shiftKey
{
/// <summary>
/// MainWindow.xaml の相互作用ロジック
/// </summary>
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
}
private void Button_Click(object sender, RoutedEventArgs e)
{
if (Keyboard.IsKeyDown(Key.LeftShift))
{
System.Console.WriteLine("PHOTON TOPEDO!");
}
else if (Keyboard.IsKeyDown(Key.LeftAlt))
{
System.Console.WriteLine("Alert: Self-destruct sequence is activated.");
}
else {
System.Console.WriteLine("photon topede");
}
}
}
}
결과
위에서 차례로,
기술 영어
검색 키워드
(C++ Builder에서 사용하는 것)
Reference
이 문제에 관하여(Visual Studio | WPF > 마우스 왼쪽 클릭 + Shift (또는 Alt 키) 감지 > Keyboard.IsKeyDown | Key.LeftShift | Key.LeftAlt), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://qiita.com/7of9/items/d0948d539d79413434f6텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념 (Collection and Share based on the CC Protocol.)