If you open up the RPG Maker VX help file and search for 'Input', it will list the keys that are available for use (DOWN LEFT RIGHT UP, A B C X Y Z L R, SHIFT CTRL ALT, F5 F6 F7 F8 F9). You can use combinations of these keys, as well :
Input.press?(Input::SHIFT) && Input.press?(Input::F5)
If you want more keys than what is listed, you'll have to use a third party key input module. I personally like using
Glitchkey's script when I need extra keys. However, I do not believe that you can use the F1 key as it has been designated by the RPG Maker system menu.
To get the quest window to open up anywhere by pressing a key is fairly simple. Within the Scene_Map code, under the 'update' method, you would just add in an 'if' statement to check to see if the key has been pressed and then check to see if the Quest Log window is open.
# You can call this window anywhere by using the following in a script input box : Quest_Log.new
# To make sure that the player doesn't open multiple quest windows before closing the first,
# you can call the script like so : Quest_Log.new unless $QUEST_LOG_WND != nil
# Sets a Global Variable; this will keep track of if the window is currently
# open or not.
$QUEST_LOG_WND = nil
# To catch keyboard strokes, we need a reliable way of calling the update
# method within our Quest_Log window. Scene_Map is updated every frame, so
# we'll use that to make sure our window is both updated and terminated
# properly since our window can't update itself without causing a fatal
# loop.
class Scene_Map
# We'll make an alias of Scene_Map's terminate and update so we don't
# over-write the methods, thus increasing compatability with other scripts.
alias quest_log_terminate terminate unless $@
def terminate
# We'll call our alias first.
quest_log_terminate
# Dispose of the Quest_Log window unless it isn't open.
$QUEST_LOG_WND.dispose unless $QUEST_LOG_WND == nil
end
alias quest_log_update update unless $@
def update
# We'll call our alias first.
quest_log_update
# Update the Quest_Log window unless it isn't open.
$QUEST_LOG_WND.update unless $QUEST_LOG_WND == nil
# Using Glitchkey's Key Input Module to catch the '1' key to open the
# quest window.
# .trigger? is better in this case than .press? because if the player
# holds down the button, the Quest Log window will flash quickly because
# it is being updated every frame.
if Keys.trigger?(Keys::N1)
# When the '1' key is pressed and the Quest Log window isn't open ...
if $QUEST_LOG_WND == nil
# Play a sound.
RPG::SE.new('Decision2.ogg', 100, 100).play
# Open a new Quest Log window.
Quest_Log.new
else # When the '1' key is pressed and the Quest Log window is open ...
# Play a sound.
Sound.play_cancel
# Close the Quest Log window.
$QUEST_LOG_WND.dispose
end
end
end
end # Scene_Map
class Quest_Log < Window_Selectable
def initialize
super(0,270,545,146)
# We'll set the Global Variable to the current window. Now it will update
# and terminate properly.
$QUEST_LOG_WND = self
@@quest_log = $game_variables[1]
# We'll call the refresh method to display the text. Keep in mind that
# currently, the player can run around with this window open and might
# complete quests while showing the old data.
refresh
end
def refresh
# Clear the current contents
self.contents.clear
case @@quest_log
when 1
self.contents = Bitmap.new(width-32, height-32)
self.contents.font.name = "Arial"
self.contents.font.size = 22
text = "The Sailor spoke of a mysterious island to the west."
self.contents.draw_text(0, 0, 600, 32, text)
when 2
# etc ...
end
end
def dispose
# Make sure the Global Variable is set to nil when closing the window.
$QUEST_LOG_WND = nil
# Dispose of the window.
self.contents.dispose
super
end
def update
refresh
end
end # Quest_Log
EDIT: You were getting close on your last attempt to play a sound. There's a few ways to do it, but you can just use this and it will work :
# Insert the name of the file with extension. Volume is a number from 0 to 100. Pitch is a number from 0 to 150; default speed is 100.
Audio.se_play("Audio/SE/<file-name>", volume, pitch)
# This also works ...
RPG::BGM.new("<file-name>", volume, pitch).play
Also, putting a sound effect in the update method is a bad idea. Remember, the update is being called around 60 times every second. That means your sound effect is trying to play itself that many times. Instead, call it in the initialize and it will only be played when the window is created.
Alternatively, if you just wanted to use the sound of a menu being opened, you could use the system default sound :
Sound.play_decision