Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


how to write keypress code to run funciton with Specifiedkey

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting
View previous topic :: View next topic  
Author Message
cancandodo
Advanced Cheater
Reputation: 0

Joined: 09 Mar 2012
Posts: 76

PostPosted: Tue Jul 07, 2026 6:58 pm    Post subject: how to write keypress code to run funciton with Specifiedkey Reply with quote

function CETrainer_CheckListBox1KeyPress(sender,VK_RETURN)

print("test")


return VK_RETURN
end

=========================
i want to press "Enter" key to run function
but this code,whatever i press any key,it runs

how to write code,only press "enter" can run this function
Back to top
View user's profile Send private message
Corroder
Grandmaster Cheater Supreme
Reputation: 75

Joined: 10 Apr 2015
Posts: 1679

PostPosted: Wed Jul 08, 2026 10:10 am    Post subject: Reply with quote

Code:

-- 1. Define the event function
function CheckListBox1KeyDown(sender, key)
    -- Check if the pressed key is the Enter key (VK_RETURN)
    if key == VK_RETURN then
        print("Enter key was pressed!")
       
        -- Run your custom logic here
        myCustomFunction()
       
        -- Return 0 to prevent the key from triggering default Windows behaviors
        return 0
    end
   
    -- Return the original key for any other button presses
    return key
end

-- 2. Bind the function to your UI element
-- (Replace 'CETrainer.CheckListBox1' with your actual form and element names)
CETrainer.CheckListBox1.OnKeyDown = CheckListBox1KeyDown


-- Your custom function to execute
function myCustomFunction()
    print("Executing custom action...")
end

_________________
Stealing Code From Stolen Code...
And Admit It.. Hmmm....Typically LOL
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites