Skip to content

Instantly share code, notes, and snippets.

@unarist
Created August 22, 2014 03:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save unarist/d86f108d67ee77f15fe4 to your computer and use it in GitHub Desktop.
Save unarist/d86f108d67ee77f15fe4 to your computer and use it in GitHub Desktop.
同時押しのキー数を数える
/*
同時押しのキー数を数える 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