本文整理汇总了C#中GameStateManagement.InputState.NewPressedKeys方法的典型用法代码示例。如果您正苦于以下问题:C# InputState.NewPressedKeys方法的具体用法?C# InputState.NewPressedKeys怎么用?C# InputState.NewPressedKeys使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GameStateManagement.InputState
的用法示例。
在下文中一共展示了InputState.NewPressedKeys方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnInput
public override void OnInput(InputState input)
{
Keys[] pressedKeys = input.NewPressedKeys().ToArray();
for (int i = pressedKeys.Length - 1; i >= 0; i--)
{
Keys pressedKey = pressedKeys[i];
int pressedKeyNum = (int)pressedKey;
if (pressedKey >= Keys.A && pressedKey <= Keys.Z)
{
Value += (char)((input.IsKeyPressed(Keys.LeftShift) || input.IsKeyPressed(Keys.RightShift)) ? pressedKeyNum : pressedKeyNum + 32);
}
else if (pressedKey == Keys.Space) Value += " ";
else if (pressedKey == Keys.Back && Value.Length > 0) Value = Value.Substring(0, Value.Length - 1);
//if (input.Mapping.Chars().ContainsKey(pressedKey)) Value += input.IsKeyPress(input.Mapping.Shift) ? input.Mapping.Chars()[pressedKey] : (char)(input.Mapping.Chars()[pressedKey] + 32);
//else if (input.Mapping.Numbers().ContainsKey(pressedKey)) Value += input.Mapping.Numbers()[pressedKey].ToString();
//else if (pressedKey == input.Mapping.Hyphen || pressedKey == Key.Minus) Value += input.IsKeyPress(Key.ShiftLeft) ? "_" : "-";
//else if (pressedKey == input.Mapping.Point) Value += input.IsKeyPress(Key.ShiftLeft) ? ":" : ".";
//else if (pressedKey == input.Mapping.Comma) Value += input.IsKeyPress(Key.ShiftLeft) ? ";" : ",";
//else if (pressedKey == input.Mapping.Space) Value += " ";
//else if (pressedKey == input.Mapping.Back && Value.Length > 0) Value = Value.Substring(0, Value.Length - 1);
}
base.OnInput(input);
}