Skip to content
This repository has been archived by the owner on Mar 28, 2023. It is now read-only.
/ mJS Public archive

m.js - event.keyCode for mobile support

Notifications You must be signed in to change notification settings

pvzzombs/mJS

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 

Repository files navigation

mJS

CodeFactor
A mini-javascript library for determing key values oninput
Best use for mobile and devices that doesn't support onkeyup and onkeydown event detection.
Download

Usage

The reason why this library exist is because of the conflict that android soft keyboards are not properly returning the correct key code. So here it is and how it is used:

Step 1. Include mJS in your document head

<script src="m.js"></script>

Step 2 Get the key by putting the m.getKey() function to the textarea's oninput event.
Pass it with params, the first one is the textarea value. The second one is an optional array that contains 2 empty strings.
It would return an array containing 2 values, the first value is the key and the second is the index Example :

<textarea id="sample" oninput="copy(m.getKey(this.value,a))"></textarea>
<script>
  var a = ["",""];
  function copy(val){
      console.log("The key is " + val[0] + "and the index is " + val[1]);
  }
</script>


How it works

It captures each key you type, then it is stored in a array. Each time you type, the string that is stored in the array is compared to the old string. If a new character is found in the new string, then it is the character you typed.

That's it thanks for using.

About

m.js - event.keyCode for mobile support

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published