Click on a button using custom keyword

Hello, i have checked about custom keyword on the community and however i am not able to proceed with the technical implementation. Please find below my code to click on the button:

try {
WebUI.click(findTestObject('scr_MemorityPassword/button_log In'))
if (WebUI.waitForElementVisible(GlobalVariable.var_authenticationFailed, 2, FailureHandling.OPTIONAL)) {
    throw new StepErrorException(GlobalVariable.var_verifyUsernamePassword) }}catch(StepErrorException e) {
WebUI.closeBrowser()
KeywordUtil.markFailedAndStop(GlobalVariable.var_loginIssue)}

I want to have same logic in a custom keyword. Could you please help?

@ThanhTo grateful if you could help?

You may need training if you can’t write computer code. Sorry, we cannot provide that here on the forum.