• Advertisement
Sign in to follow this  

What key is this ~ in XNA Keys

This topic is 1902 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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?

[url="http://msdn.microsoft.com/en-us/library/microsoft.xna.framework.input.keys.aspx"]http://msdn.microsof...input.keys.aspx[/url]

[CODE]example keyboardState.IsKeyDown(Keys. ?!!!)[/CODE]

[img]http://upload.wikimedia.org/wikipedia/commons/4/49/Tilde_key.jpg[/img] Edited by FantasyVII

Share this post


Link to post
Share on other sites
Advertisement
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.

[CODE]
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;
}
[/CODE] Edited by FantasyVII

Share this post


Link to post
Share on other sites
[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.

[CODE]
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;
}
[/CODE]
[/quote]

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] Edited by Xanather

Share this post


Link to post
Share on other sites
[quote name='Xanather' timestamp='1352095333' post='4997452']
[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.

[CODE]
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;
}
[/CODE]
[/quote]

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

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement