You can pass event to the function from which you can access the property keyCode.

But I would recommend you to see the documentation before using KeyboardEvent.keyCode

You should avoid using this if possible; it's been deprecated for some time. Instead, you should use KeyboardEvent.code, if it's implemented. Unfortunately, some browsers still don't have it, so you'll have to be careful to make sure you use one which is supported on all target browsers. Google Chrome and Safari have implemented KeyboardEvent.keyIdentifier, which was defined in a draft specification but not the final spec.

function callMyFunction (e, importantothervalue) {
  console.log(e.code);
  console.log(importantothervalue)
}
<textarea onkeyup="callMyFunction(event, 1);"></textarea>
<textarea onkeyup="callMyFunction(event, 2);"></textarea>
<textarea onkeyup="callMyFunction(event, 3);"></textarea>

Answer from Mamun on Stack Overflow
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › API › Element › keyup_event
Element: keyup event - Web APIs | MDN
September 25, 2025 - Note: Unlike keydown, keyup events do not have special keyCode values for IME events.
Discussions

javascript - How to find out the key pressed on keyup or keypress event when dollar key is pressed - Stack Overflow
This is not an answer. Events have a shiftKey property as mentioned by others, but no Shift (nor even a shift) property, and they have a keyCode property but no KeyCode property. And, as far as I can tell, no browser has a Keys global either. More on stackoverflow.com
🌐 stackoverflow.com
javascript - keypress and keyup - why is the keyCode different? - Stack Overflow
I can understand why one should ... the keyboard, give different keyCodes. PS: I'm not worrying about legacy browsers support, I tried this in Chrome and was surprised, and couldn't find an explanation. ... The question onKeyPress Vs. onKeyUp and onKeyDown is somewhat related ... More on stackoverflow.com
🌐 stackoverflow.com
jquery - JavaScript .on("keyup") - Stack Overflow
There's an input text fires a function on "onkeyup" event. When that function fires I'm binding a "keyup" event with .on("keyup") method to get the last pressed key to find out if it was alphanumer... More on stackoverflow.com
🌐 stackoverflow.com
Javascript onKeyUp - Stack Overflow
so I'm working on a mock version of google censorship for history class. I'm trying to get the search to work upon pressing enter, but so far all I get is a search upon the first letter I enter. Any More on stackoverflow.com
🌐 stackoverflow.com
🌐
W3Schools
w3schools.com › jsref › event_onkeyup.asp
onkeyup Event
altKey (Mouse) altKey (Key) animationName bubbles button buttons cancelable charCode clientX clientY code ctrlKey (Mouse) ctrlKey (Key) currentTarget data defaultPrevented deltaX deltaY deltaZ deltaMode detail elapsedTime elapsedTime eventPhase inputType isTrusted key keyCode location metaKey (Mouse) metaKey (Key) newURL oldURL offsetX offsetY pageX pageY persisted propertyName relatedTarget relatedTarget screenX screenY shiftKey (Mouse) shiftKey (Key) target targetTouches timeStamp touches type which (Mouse) which (Key) view HTML Event Methods
🌐
JavaScript.info
javascript.info › tutorial › browser: document, events, interfaces › ui events
Keyboard: keydown and keyup
kinput.onkeydown = kinput.onkeyup = kinput.onkeypress = handle; let lastTime = Date.now(); function handle(e) { if (form.elements[e.type + 'Ignore'].checked) return; area.scrollTop = 1e6; let text = e.type + ' key=' + e.key + ' code=' + e.code + (e.shiftKey ?
🌐
GeeksforGeeks
geeksforgeeks.org › html › html-onkeyup-event-attribute
HTML onkeyup Event Attribute - GeeksforGeeks
August 5, 2025 - HTML onkeyup Event Attribute · In JavaScript, use the keyup event listener on the textbox, then check if the event's keyCode or `key` property equals 13, indicating the Enter key press.
Find elsewhere
🌐
Toptal
toptal.com › developers › keycode
JavaScript Key Code Event Tool | Toptal®
KeyCode.Info allows users to press any key and instantly get the JavaScript Key or Key Code KeyboardEvent. Check out the Tool and Event List.
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › API › KeyboardEvent › keyCode
KeyboardEvent: keyCode property - Web APIs | MDN
The deprecated KeyboardEvent.keyCode read-only property represents a system and implementation dependent numerical code identifying the unmodified value of the pressed key.
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › API › Element › keydown_event
Element: keydown event - Web APIs | MDN
eventTarget.addEventListener("keydown", (event) => { if (event.isComposing || event.keyCode === 229) { return; } // do something });
🌐
tutorialpedia
tutorialpedia.org › blog › is-it-possible-to-get-the-key-code-from-onkeyup
How to Retrieve Key Code from HTML onkeyup Event While Passing Additional Values in JavaScript — tutorialpedia.org
Use event.key/event.code Over keyCode Avoid keyCode (deprecated). event.key is more readable and consistent. Avoid Inline Handlers for Large Apps For complex applications, use addEventListener instead of inline onkeyup to separate HTML and JavaScript: // Better: Attach event via JavaScript const input = document.getElementById("username"); input.addEventListener("keyup", (event) => { handleKeyUp(event, "username"); // Pass additional value here }); Sanitize Additional Values If passing user-generated or dynamic values, sanitize them to prevent XSS attacks (e.g., with DOMPurify for HTML content).
🌐
jQuery
api.jquery.com › keyup
keyup event | jQuery API Documentation
Description: Bind an event handler to the "keyup" event · This page describes the keyup event. For the deprecated .keyup() method, see .keyup()
🌐
Eddie Jackson
eddiejackson.net › wp
JavaScript – Key Codes – Lab Core | The Lab of MrNetTek
September 25, 2018 - The keyCode property returns the Unicode character code of the key that triggered the onkeypress event, or the Unicode key code of the key that triggered the onkeydown or onkeyup event.
🌐
W3Schools
w3schools.com › jquery › event_keyup.asp
jQuery keyup() Method
W3Schools offers free online tutorials, references and exercises in all the major languages of the web. Covering popular subjects like HTML, CSS, JavaScript, Python, SQL, Java, and many, many more.
🌐
OutSystems
outsystems.com › forums › discussion › 57835 › reactive-onkeyup-enter-key
Reactive onkeyup enter key | OutSystems
February 20, 2020 - Loving reactive but I have a challange, the onkeyup function works great but I want to filter on the key that is going up. Any idea how to do this in reactive · The event.keyCode is giving me no result but this works:
🌐
W3Schools
w3schools.com › jsref › event_key_keycode.asp
KeyboardEvent keyCode Property
The keyCode property is deprecated. Use the key property instead. ... If you want to use W3Schools services as an educational institution, team or enterprise, send us an e-mail: sales@w3schools.com · If you want to report an error, or if you want to make a suggestion, send us an e-mail: help@w3schools.com · HTML Tutorial CSS Tutorial JavaScript Tutorial How To Tutorial SQL Tutorial Python Tutorial W3.CSS Tutorial Bootstrap Tutorial PHP Tutorial Java Tutorial C++ Tutorial jQuery Tutorial
🌐
Sky
qtools.skyq.sky.com › htmltestapps › keycodes › index.html
JavaScript Event KeyCode Test Page
JavaScript Event KeyCode Test Page · Input: · onKeyDown · onKeyPress · onKeyUp · event.keyCode · event.charCode · event.which