-- Keyboard script
function OnKeyPress(_key)
  
   if _key == 1 then
     
     -- ESC video play
	 if states["sys_video_play"] ~= "" and states["sys_video_play"] ~= 0 then 
		Video:StopMovie(states["sys_video_play"])
		print ("ESC video..")
		return 
	 end
  if UI:WidgetExists( "item_big") then 
    UI:DelWidget("item_big")
    return 
  end
  if s.sys_block_only_esc == 1 then return end 
	if states["sys_block_esc"] ~= 0 or s.hold == 1 then
		return
	end
  

  
  if MystInventory:GetActive():GetSelectedItem() ~= "" then
		MystInventory:GetActive():ReleaseItem()
	end
	
   -- interface
    if DiaryWidget ~= nil and DiaryWidget:IsVisible() then
      DiaryWidget:SetVisible(false)
      return
    end
    if HintWndBox ~= nil and HintWndBox:IsVisible() then 
	  Widgets.hint_window_box.Close() 
	  return 
	end
	 
    --submenu2
        if s.sys_menu_opt_snd==1 then
          Widgets.opt_snd.self:SetVisible(false)
          Widget("MainMenu"):SetVisible(true)
    --submenu       
        elseif s.sys_menu_credits==1 then
            Credits:SetVisible(false)
            Widget("MainMenu"):SetVisible(true)
        
        elseif s.sys_menu_solution == 1 then -- hook
        elseif s.sys_menu_profile  == 1 then -- hook
        --game
        elseif s.sys_game_start == 1 and s.sys_menu == 0 then 
            s.sys_menu = 1
            OpenMainMenu()
            OpenInventory()          
            s.sys_menu_hide=0            
        elseif s.sys_game_start == 1 and s.sys_menu == 1 then 
            s.sys_menu = 0
            if scene_nodes.s00_0000_menu ~= nil then
              scene_nodes.s00_0000_menu.OnGameResume()
            else
              ResumeGame()
            end
            OpenInventory()
            s.sys_menu_hide=1
        end

    end
end 

function OnKeyRelease(_key)

end