What key is this ~ in XNA Keys

Started by
4 comments, last by FantasyVII 11 years, 5 months ago
Hello everyone,

I went to the MSDN try to find the enum name for this key ` but I can't find it. So do guys know what is the key name?

http://msdn.microsof...input.keys.aspx

example keyboardState.IsKeyDown(Keys. ?!!!)

Tilde_key.jpg
Advertisement
~ is a tilde

~ is a tilde


thanks :)
one more thing. lets say when I press the tilde key I want to set a boolean to be true and keep it true until I press it again I want to set it to false. how can I do that?

this is what I got so far.


public void Update()
{
newState = Keyboard.GetState();

if (newState.IsKeyDown(Keys.OemTilde) && oldState.IsKeyUp(Keys.OemTilde))
Enable = true;

if (newState.IsKeyUp(Keys.OemTilde) && Enable == true)
Enable = false;

oldState = newState;
}

one more thing. lets say when I press the tilde key I want to set a boolean to be true and keep it true until I press it again I want to set it to false. how can I do that?

this is what I got so far.


public void Update()
{
newState = Keyboard.GetState();

if (newState.IsKeyDown(Keys.OemTilde) && oldState.IsKeyUp(Keys.OemTilde))
Enable = true;

if (newState.IsKeyUp(Keys.OemTilde) && Enable == true)
Enable = false;

oldState = newState;
}



The following code should work...
[source lang="csharp"] public KeyboardState keyboardstate;
public KeyboardState keyboardstateprev;
public bool enabled;
protected override void Update(GameTime gameTime)
{
keyboardstate = Keyboard.GetState();
if (keyboardstate.IsKeyUp(Keys.Enter) && keyboardstateprev.IsKeyDown(Keys.Enter))
{
if (enabled)
{
enabled = false;
}
else
{
enabled = true;
}
}
keyboardstateprev = keyboardstate;
base.Update(gameTime);
}[/source]

[quote name='FantasyVII' timestamp='1352078281' post='4997372']
one more thing. lets say when I press the tilde key I want to set a boolean to be true and keep it true until I press it again I want to set it to false. how can I do that?

this is what I got so far.


public void Update()
{
newState = Keyboard.GetState();

if (newState.IsKeyDown(Keys.OemTilde) && oldState.IsKeyUp(Keys.OemTilde))
Enable = true;

if (newState.IsKeyUp(Keys.OemTilde) && Enable == true)
Enable = false;

oldState = newState;
}



The following code should work...
[source lang="csharp"] public KeyboardState keyboardstate;
public KeyboardState keyboardstateprev;
public bool enabled;
protected override void Update(GameTime gameTime)
{
keyboardstate = Keyboard.GetState();
if (keyboardstate.IsKeyUp(Keys.Enter) && keyboardstateprev.IsKeyDown(Keys.Enter))
{
if (enabled)
{
enabled = false;
}
else
{
enabled = true;
}
}
keyboardstateprev = keyboardstate;
base.Update(gameTime);
}[/source]
[/quote]

thank you very much it works :D

This topic is closed to new replies.

Advertisement