ASCII and vk_constants

Zaksley

Member
Hi there.
I'm trying to create a menu where the player can change his controls.
It works fine for the normal values and for some specials values like SPACE or ESCAPE.

But for ALT, CTRL, SHIFT, .. I'm stuck.
I guess it's because those controls aren't in the ASCII table (http://www.asciitable.com/).

So, any idea ?

Here is my script to display the commands.

Code:
var xx = argument0
var yy = argument1
var value = argument2

switch(value)
{
   
    case chr(vk_control):
        draw_text(xx, yy, "CTRL");
        break;
   
    case chr(vk_space):
        draw_text(xx, yy, "SPACE")
        break;

       
    case chr(vk_alt):
        draw_text(xx, yy, "CTRL");
        break;
   
    case chr(vk_shift):
        draw_text(xx, yy, "SHIFT");
        break;
       
    case chr(vk_escape):
        draw_text(xx, yy, "ESC")
        break;
       
    default:
        draw_text(xx, yy, value);
        break;
   
   
}

The value is a key[0 to 4] equals to a chr(control).

And because chr(vk_alt) / chr(vk_control) / chr(vk_shift) aren't working (I'm not sure but I think here is the mistake), I don't know how to show "ALT" "CTRL" and "SHIFT" if the player use one of this keyboard.
Any idea?
 

FrostyCat

Redemption Seeker
If the source values are from places like keyboard_key, just get rid of the chr() and the comparisons will work.

Also, your Alt check still tries to draw CTRL.
 

Zaksley

Member
The source values is keyboard_lastchar, that's why I believe Control/Alt/... don't work.
I'm going to try to use keyboard_key instead but when I used keyboard_lastkey I had way more issues.
 

Gamebot

Member
//This is part an input box of mine.

Code:
key = keyboard_key;

  if (string_count(chr(key), keys) == 1 || key > 127)
 {   
  blink = true;
  pos++; cursx += wid;
  txt[@ line] = string_insert(keyboard_lastchar, txt[@ line], pos);
 }

// Check for "vk" keys such as shift, control, enter...
if (!keyboard_check(vk_control) && !keyboard_check(vk_shift) && !(keyboard_check(vk_alt)))
{
 switch(keyboard_lastkey)
 {
  case vk_enter:     scr_enter();     break;
  case vk_delete:    scr_del();    break;
  case vk_backspace: scr_backspace(); break;
 
  case vk_up:
  if (line > 0){
  var poscheck = string_length(txt[@ line - 1]);
  if (pos > poscheck) {pos = poscheck}
  line--;  }
  break;
 
  case vk_down:
  if (line < totlines - 1) {
  var poscheck = string_length(txt[line + 1]);
  if (pos > poscheck) {pos = poscheck}
  line++;         }
  break;
 
 case vk_right:
 if (pos != len) {pos ++;}
 else if (pos = len && line != totlines - 1) {pos = 0; line++;}
 else {exit;}
 break;
 
 case vk_left:
 if (pos != 0) {pos --;}
 else if (pos = 0 && line != 0) {pos = string_length(txt[line - 1]); line--;}
 else{exit}
 break;
 }
}
 
Top