AKM Add-On #1: NF Key State Detection
#1
ALEWORKS KEYS MODULE
ADD-ON #1

(Fantastica Key State Detection)
version 1.0

by DerVVulfman
Based on routines by Aleworks (vgvgf)
and Jaime 'Near Fantastica' Webster


Introduction
This script is an add-on for use with the Aleworks Keys Module(AKM). Its purpose... to allow the system to detect the input from the keyboard and return the actual 'code' for the key.


Related Links
Aleworks Input Module
Keyboard Input Module


Features
  • Detects each available key mapped by the system using Aleworks's system
  • Detection routines broken into subgroups... check for letters, or numbers, or both
  • Returns the actual 'Character' or 'Key Code' for each key (recorded in the AKM).
  • Returns additional 'Characters' or 'Key Codes' for keys based on the keyboard state (SHIFT/NUMLOCK)
  • Key detection can be set to press? or trigger? in responsiveness.
Screenshots
Huh? This is an input module. Look at how your fingers dance across your keyboard. ;)


Demo
Aleworks System with the AKM Add-On
Includes Aleworks Library, AIM, AIM CP1, AIM Add-On 1, AIM Add-On 2, and AKM


Script
The Script


Instructions
Paste it below Aleworks Keys Module. If your system does not use U.S OEM keys, you may wish to change the returned values in the OEM_NAMES and SH_OEM_NAMES arrays.


Methods
This add-on, as stated, allows the system to detect the input from the keyboard and return the actual 'code' for the key. What does that mean? Simple. Instead of getting a true/false value from the system... you get the actual button pressed. But... if no button is pressed, it will return 'nil'.

Example:
Code:
    @key_returned = Keys.get_letters
If the player presses the 'a' button, the method will return the letter 'a' (or 'A' if the shift button was pressed).

Note: In all the calls descibed below, the trigger_on value (a true/false value), is totally optional. By default, it is set to false and would retrieve data from the keyboard in the manner of the Input.press? system (very rapidly). However, setting the value to true will allow the data to be retreived in the manner of the Input.trigger? fashion.

The Method Calls

Keys.get_direction(trigger_on)
This method returns a string describing the key press on the directional keypad. This method also returns numeric values (as strings) if the Number Lock button is on. If no directional key is pressed, this method returns a 'nil' value

Keys.get_function(trigger_on)
This method returns a string that describes specific function keys such as Escape, Enter, F3, F10, Control, Alt, and even the Backspace key. If no function key is pressed, this method returns a 'nil' value.

Keys.get_individual(trigger_on)
This method returns a string that describes very specific function keys such as the CAPSLOCK, LF ALT, RT CTRL, and APPS buttons. Again, if no individual key is pressed, this method returns a 'nil' value.

Keys.get_letters(trigger_on)
This method simply returns an alphabetic character, but moreso... it takes into consideration the Shift and Capslock buttons to determine if the character returned is capitalized or lowercase. Likewise, if no letter key is pressed, this method returns a 'nil' value.

Keys.get_numbers(trigger_on)
This method simply returns a string for each number along the top of the keyboard. Please remember that these are 'strings' and are not numeric values. Also remember that these keys pertain only to the top row keys on the keyboard and not the directional keypad. And again, if no number key is pressed, this method returns a 'nil' value.

Keys.get_key(trigger_on)
This method returns all other symbolic keys on the keyboard. These may be the 'shifted' versions of the number keys ( !@#$ and etc. ) or they may be keys such as the slash (\) or backslash(/) keys. And this method also returns a 'blank space' if the spacebar is pressed. Finally, it will return 'nil' if this method doesn't detect a key pressed.

Keys.get_keyboard(trigger_on)
This method returns the alphabetic, numeric and symbolic characters keys on the keyboard. Very simply, it is a culmination of the get_letters, get_numbers and get_key methods.



OEM_NAMES & SH_OEM_NAMES
These are two arrays that store the string returned for a handful of keys in your system. These are mainly characters such as ;, % and the like in accordance to the layout on your keyboard. These strings may change based on the keyboard you are using. Like the KEYS_NAMES array in AKM, they are stored as a CONSTANT array within the Keys module.

The inclusion of the Backtab and Center strings in these arrays is to allow the return the little-used Backtab key (Shift + Backspace) and the detection of the '5' button on the directional keypad when the NumLock button was off (the only unused button).


KEY CODES
For the mostpart, the keycodes you would use or have returned in the system are the same as the Constants and Letters you would normally use. In case you were not sure the spelling of the returned keys are (including capitalization):
AKM's KEYS_NAMES Array
AKM #1's


Compatibility
SDK Compatible but not required (the demo includes a non-SDK rewrite of AIM Add-On #2... the only one that needed it).

This add-on is designed for use with the Aleworks Keys Module(AKM), and no other. However as a module, it should not interfere with any other system unless said system IS a keyboard/input module that uses similar method names and/or values.


Credits and Thanks
Thanks goes to both Aleworks(Vgvgf) and Jaime 'Near Fantastica' Webster for the creation of their respective works. And credit goes to Wyatt for requesting this merger.

[Image: xp_warning.png]
Image has link to Enterbrain's Download Page
Reply }


Possibly Related Threads…
Thread Author Replies Views Last Post
   OS Detection via Ruby DerVVulfman 3 5,717 09-09-2019, 05:33 AM
Last Post: kyonides
   States Activation System aka State-Based Passive Augments, Version 0.2 Charlie Fleed 7 12,911 03-06-2010, 09:26 PM
Last Post: fgsfds
   State Cycling Trickster 0 4,890 03-02-2008, 06:54 AM
Last Post: Trickster
   Elemental and State Rates Trickster 0 4,528 03-02-2008, 04:32 AM
Last Post: Trickster



Users browsing this thread: 1 Guest(s)