View Single Post
  #2  
Old 06-27-2006, 07:05 AM
ApothiX ApothiX is offline
Okiesmokie
Join Date: May 2004
Posts: 1,447
ApothiX is on a distinguished road
http://en.wikipedia.org/wiki/Scancode

http://en.wikipedia.org/wiki/Scancode

Edit: Received a PM from the maker of the thread requesting more information, and not just a link with "someone else's words" on it.

A simple method of determining what key has what scancode can be scripted. This script does just that (In old-gscript for compatibility with the editor, it's not likely that you'd want to upload something like this to a server.)

PHP Code:
//#CLIENTSIDE
if(createdtimeout 0.05;

if(
timeout) {
  for(
i=0;i<256;i++) {
    if(
keydown2(i,true)) {
      
setplayerprop #c,Scancode: #v(i);
    
}
  }

  
timeout 0.05;

That will tell you which key has which scancode, you can then go ahead and use the onKeyDown event as follows:

PHP Code:
function ControlName.onKeyDown(keycodekeystringscancode) {
  if(
scancode == 65) {
    
player.chat "The a key was pressed while ControlName had focus.";
  }

a more simpler method of this, as scancodes change depending on the keyboard layout (I believe, could be wrong though) would be to just check for the character.

PHP Code:
function ControlName.onKeyDown(keycodekeystringscancode) {
  if(
keystring == "a" || keystring == "A") {
    
player.chat "The a key was pressed while ControlName had focus.";
  }

I'm not sure what the 'keycode' is exactly, but it probably has something to do with the standard game controls, like keydown().

Quote:
keydown( key ) the specified key is pressed (0..10: up,left,down,right,S,A,D,M,tab,Q,P)

Edit again: <_< Now that I re-read it, keycode and scancode may be mixed up in those examples. I haven't done this for awhile so you may want to double check that. Scancode can still be determined using a method similiar to this, although all scancodes are shown on the wiki page I linked to.
__________________


[06:24:19] * Parts: Skyld (i=silent@unaffiliated/skyld) ("Perhaps Okiesmokie did not realise that I like the boys. ")

Last edited by ApothiX; 06-27-2006 at 07:39 AM..
Reply With Quote