📅  最后修改于: 2022-03-11 14:48:56.139000             🧑  作者: Mango
private string text = string.Empty;
protected override void Update(GameTime gameTime)
{
KeyboardState keyboardState = Keyboard.GetState();
Keys[] keys = keyboardState.GetPressedKeys(); // Get an array of all the pressed keys.
if(keys.Length > 0)
{
var keyValue = keys[0].ToString(); // Get the first element of the array and convert it to a string.
text += keyValue; // Add it to text.
}
base.Update(gameTime);
}