Created
August 22, 2014 03:24
-
-
Save unarist/d86f108d67ee77f15fe4 to your computer and use it in GitHub Desktop.
同時押しのキー数を数える
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
同時押しのキー数を数える by unarist | |
押して離したタイミングでカウント。 | |
*/ | |
var form = new Form(); | |
var view = new Label{Dock=DockStyle.Fill}; | |
form.Controls.Add(view); | |
var keys = new HashSet<Keys>(); | |
var log = new int[16]; | |
var active = false; | |
form.KeyDown += (o,e) => { | |
keys.Add(e.KeyCode); | |
active = true; | |
}; | |
form.KeyUp += (o,e) => { | |
if(active) { | |
log[keys.Count] += 1; | |
active = false; | |
view.Text = string.Join("\n", log.Select((n,i) => string.Format("{0}:{1}",i,n))); | |
} | |
keys.Remove(e.KeyCode); | |
}; | |
Application.Run(form); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment