Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 Keyboard Input Module (Revised)
#1
Keyboard Input Module (Revised)
Revision 1.2
based on Jaime 'Near Fantastica' Webster's system


Introduction
"I know there is a few keyboard input scripts out there but not like this one... this one works fundamentally different then the others you press and key and it returns what was pressed... which lets you easily have string input for names, conversations, or what ever you see fit." - Near Fantastica

Pretty much what he said. :thumb:

This system is not a name input module, a message system or menu system that uses keyboard input. This is the basic module that you would use to CREATE such systems. It reads keyboard presses, be they letter characters, shift keys, or whatnot and allows you to access them in place of the default systems' routines.

Now far be it from me to just post my own system without acknowleding Near Fantastica's original work. Without his work, this wouldn't be available. As such, I am posting his script in this topic along with the newly revised system.


Script
Keyboard Input Module (Revised)
NOTE:
In this 'revised' version, I have included [Caps Lock] for determining capital letters and [NumLock] for changing the functions on the numeric keypad. I have also revised the code and added the ability to detect individual 'left' and 'right' function keys (left shift, right shift, left alt, etc.). Even with the inclusions, it is still smaller than Near Fantastica's system.

...and the original v3 script
Keyboard Input Module (Original Version)
NOTE:
This system (when acquired) referred to a 'wow' method that was not included in this system. It was used to generate the actual alphanumeric character/number (from the ascii value) to be returned. Somehow it was a 'mis'-copy and the actual method used was a 'chr'. This has been corrected.

Presented in the original format (minus the 'wow' error) I was able to obtain from 'Creation Asylum.'


Instructions
This script is used to detect keys being pressed and return them for use in your scripts... whether it is a message script, a custom menu system or advanced battlesystem. This script alone accomplishes nothing unless you create a system that utilizes the calls within:

Syntax (Just like Near Fantastica's - with one addition.)
Code:
if Input.get_function   == "function"  # Keys like [Esc], [Ctrl], [Tab]
if Input.get_letters    == "letter"    # The alphabet keys (augmented by (Shift] or [Caps])
if Input.get_numbers    == "number"    # The number keys (disabled if [Shift] is being pressed)
if Input.get_key        == "char"      # All other printable keys (and top-row number keys [shift]ed)
if Input.get_direction  == "number"    # Number Pad & [Home], [PgUp] and etc.
and
if Input.get_individual == "function"  # Keys like [Left Alt], [Right Alt], [Left Shift]

Input.get_function
[SIZE="1]This call allows you to detect specialized keys such as 'Esc', 'Ctrl', 'Backspace' , 'Print Screen' and the 'F1 to F12' keys
[/SIZE]
Input.get_letters
This call allows you to detect the alphabetic characters being returned, and whether they are 'shifted' or not. Unlike cybersam's system, this detects whether the left and/or right shift buttons are being pressed so generation of capital and lowercase characters can be produced.

Input.get_numbers
This call allows you to detect the number keys (0 to 9) along the TOP of the keyboard. It does not detect any 'shifted' characters and does not detect the number keys on the keypad.

Input.get_key
This call returns most other alpha-numeric characters such as the space key, brackets and parenthesis, equals and the 'shifted' characters along the top of the keyboard.

Input.get_direction
This call returns the number keys on the directional keypad when the Numberlock is on and directional keys when it is off. It also returns keys such as PgUp, PgDown, Home and etc.

Input.get_individual
This call returns the specialized function keys of [CapsLock], [NumberLock] and [ScrollLock]. But it also detects the unique keys such as [Lf Ctrl] and [Rt Cntl] and matching ones for Alt and Shift. The pressing of [CapsLock] and [NumberLock] automatically alters the returned values of the other functions, but this function is useful if you want to detect and return the button as part of your special menu/battle/whatever system.


FAQ
Again, this system is used to detect keypresses but it is up to the end-user to create system(s) that use these key-detection functions.


Keys to NOT Consider (Unless you're real good)
As the [F1], [F2] and [F12] keys are most likely hardwired into Game.Exe or cleverly concealed within the RGSS default coding, I would not recommend testing and writing code for these. This is under the assumption that an advanced script has not been made that could disable these key's built-in functions.

Also, while detection of the Left and Right Windows key (for the Microsoft Natural keyboard) is now available, these are not recommended given as well. Not unless you can disable Windows's key reactions themselves.


Compatibility
As it adds routines to the INPUT module, it should be compatible with nearly any system. The only exception being systems that also add or edit the INPUT module that may use the same routine names... rare instances.


Example Code
Based on a small submission by GoldenShadow in N.F's post in Creation Asylum, this example shows how you can detect certain keys with this system. Just press [Esc] from the field map to bring up a 'butchered' main menu screen and press keys to your heart's content. :D

Example
Reply }


Possibly Related Threads…
Thread Author Replies Views Last Post
   Aleworks Input Mouse Sprite Add-On DerVVulfman 2 735 09-21-2023, 02:56 PM
Last Post: DerVVulfman
   Audio Module Kain Nobel 2 1,924 01-25-2022, 11:39 AM
Last Post: Kain Nobel
   Keyboard Name Input - Updated DerVVulfman 0 1,282 01-05-2022, 04:25 AM
Last Post: DerVVulfman
   DoubleX RMMV Action Input Timer DoubleX 0 2,323 09-06-2020, 06:32 AM
Last Post: DoubleX
   Audio Module Rewrite mcisendstring DerVVulfman 25 35,137 05-03-2020, 08:08 PM
Last Post: MikiIsAway
   MicKo's Skill Tree - Revised DerVVulfman 49 54,003 12-17-2019, 04:13 AM
Last Post: DerVVulfman
   DoubleX RMMV Reverse Input DoubleX 1 4,427 01-30-2016, 12:25 PM
Last Post: DoubleX
   GPLAT Pixel Platformer Revised DerVVulfman 0 4,074 10-02-2014, 04:14 AM
Last Post: DerVVulfman
   NRGSS Module Function Library Narzew 3 7,425 09-18-2012, 10:44 PM
Last Post: Narzew
   Victor Engine - Basic Module Victor Sant 0 5,744 12-21-2011, 07:46 AM
Last Post: Victor Sant



Users browsing this thread: