Please login or register.

Login with username, password and session length
Advanced search  

News:

IRC channel - server: waelisch.de  channel: #wme (read more)

Author Topic: Keyboard.IsControl usage  (Read 2796 times)

0 Members and 1 Guest are viewing this topic.

Nebz

  • Lurker
  • *
  • Karma: 0
  • Offline Offline
  • Posts: 7
    • View Profile
Keyboard.IsControl usage
« on: January 17, 2009, 02:49:33 PM »

Hello!  ::wave  I'm new to the engine and this community and a little camera shy so don't all look at once!  :-[ I'm looking forward to ask a quadrillion questions, so I better get busy. ;D

Here's my first quandary:
I'm trying to add a quick save feature to our game by creating the hotkey ctrl+s. However, I'm uncertain of how to use this combination of keys together since nothing seems to happen when I do. I use the following logic:

if (Keyboard.IsControl && ( Keyboard.Key == "S" || Keyboard.Key == "s") ) 
    RunSaveMethod(); //at this point I print something to screen but nothing gets displayed

So... What am I doing wrong here? Any help would be greatly appreciated. Thank you very much!  :)
Logged

Mnemonic

  • WME developer
  • Administrator
  • Addicted to WME forum
  • *
  • Karma: 41
  • Offline Offline
  • Gender: Male
  • Posts: 5683
    • View Profile
    • Dead:Code Site
Re: Keyboard.IsControl usage
« Reply #1 on: January 17, 2009, 05:38:10 PM »

Problem is, the Control key mutates the printable character into another character, so Keyboard.Key no longer contains "s". You'd best use Keyboard.KeyCode instead. If Keyboard.KeyCode == 19, Ctrl+S has been pressed.
Logged
Yes, I do have a twitter account
Please don't send me technical questions in private messages, use the forum. ::wave

Nebz

  • Lurker
  • *
  • Karma: 0
  • Offline Offline
  • Posts: 7
    • View Profile
Re: Keyboard.IsControl usage
« Reply #2 on: January 17, 2009, 06:26:30 PM »

I see. That makes sense. Thank you!  :)
Logged
 

Page created in 0.034 seconds with 20 queries.