Your code works for me (see below). Maybe check where you are binding your keyup event. It should be bound once when the document loads before the page shows. If you bind it multiple times (i.e. if the code that contains your keyup function runs more than once) you will run into problems.

$("#arama").on("keyup", function(event) {
  var i = event.keyCode;
  if ((i >= 48 && i <= 57) || (i >= 96 && i <= 105)) {
    $("#arama").off("keyup");
    console.log("Number pressed. Stopping...");
  } else {
    console.log("Non-number pressed.");
  }
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>

<input id="arama" />

Answer from Chris Thorsvik on Stack Overflow
🌐
W3Schools
w3schools.com › jsref › event_onkeyup.asp
onkeyup Event
The onkeyup event occurs when the user releases a key on the keyboard. The Keyboard Event Object · The onkeypress event is deprecated. It is not fired for all keys (like ALT, CTRL, SHIFT, ESC) in all browsers.
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › API › Element › keyup_event
Element: keyup event - Web APIs | MDN
Inherits from UIEvent and Event. This interface also inherits properties of its parents, UIEvent and Event. KeyboardEvent.altKey Read only · Returns a boolean value that is true if the Alt (Option or ⌥ on macOS) key was active when the key event was generated.
🌐
W3Schools
w3schools.com › tags › att_onkeyup.asp
HTML onkeyup Attribute
The onkeyup attribute fires when the user releases a key (on the keyboard).
🌐
GeeksforGeeks
geeksforgeeks.org › html › html-onkeyup-event-attribute
HTML onkeyup Event Attribute - GeeksforGeeks
August 5, 2025 - The HTML onkeyup event attribute executes JavaScript code when a user releases a key after pressing it within an input field or textarea, enabling dynamic responses to keyboard input.
🌐
W3Schools
w3schools.com › tags › ev_onkeyup.asp
HTML onkeyup Event Attribute
❮ HTML Event Attributes · Execute ... » · More "Try it Yourself" examples below. The onkeyup attribute fires when the user releases a key (on the keyboard). Tip: The order of events related to the onkeyup event: onkeydown ...
🌐
TutorialsPoint
tutorialspoint.com › article › html-onkeyup-event-attribute
HTML onkeyup Event Attribute
1 month ago - <!DOCTYPE html> <html> <head> <style> body { color: #000; height: 100vh; background: linear-gradient(62deg, #FBAB7E 0%, #F7CE68 100%) no-repeat; text-align: center; padding: 20px; } .show { font-size: 1.2rem; } </style> </head> <body> <h1>HTML onkeyup Event Attribute Demo</h1> <textarea class="" placeholder="Enter your message here" rows="5" cols="40" onkeyup="keyFn()"></textarea> <div class="show"></div> <script> function keyFn() { document.querySelector(".show").innerHTML = 'You enter: ' + document.querySelector("textarea").value; } </script> </body> </html>
Find elsewhere
🌐
Educative
educative.io › answers › difference-between-the-onkeyup-and-onkeydown-events-in-javascript
Difference between the onkeyup and onkeydown events in Javascript
onkeyup recieves a code snippet or a function to execute. onkeydown() is used when selecting the tag via id, class, or tag. onkeydown="function" // is used when attached directly to an HTML tag.
🌐
GeeksforGeeks
geeksforgeeks.org › html › html-dom-onkeyup-event
HTML DOM onkeyup Event - GeeksforGeeks
July 12, 2025 - The HTML DOM onkeyup event in HTML occurs when a key is released after pressing by the user.
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › API › Element › keydown_event
Element: keydown event - Web APIs | MDN
html · <input placeholder="Click here, then press down a key." size="40" /> <p id="log"></p> js ·
🌐
W3Schools
w3schools.com › Jsref › tryit.asp
W3Schools online HTML editor
The W3Schools online code editor allows you to edit code and view the result in your browser
🌐
Parsons
b.parsons.edu › ~kline420 › parsons-server › week-7.5
Resource: onkeydown, onkeyup
onkeyup: An event in Javascript that occurs when a user releases a key. HTML allows for the input tag, which allows the user to enter certain types of data.
🌐
Medium
frontendinterviewquestions.medium.com › keyup-event-in-angular-663a8d7abc27
keyup event in Angular. For more questions and answers visit… | by Pravin M | Medium
September 1, 2024 - In this example, the keyup event is bound to the onKeyUp() method, and $event provides access to the event data.
🌐
Mozilla
developer.mozilla.org › zh-TW › docs › Web › API › Element › keyup_event
keyup - Web APIs | MDN
December 13, 2024 - Web technology reference for developers · Structure of content on the web