I am making a php/mysql epos system for my shop which will be run from a browser on my shop PC. I have large buttons which I would like to be able to 'click' by pressing something like the F-buttons at the top of the keyboard. Is it possible to override the standard button shortcuts for a web page. This is only going to be on my shop computer so accessibility is not a problem.
I'm writing some stuff where I wish to allow the cursor keys to control elements in a page. This has not been a problem except with Safari which appears to duplicate the keydown and keyup events which are fired when the cursor keys are pressed. I.e. pressing and releasing say, K, results in one keydown event followed by one keyup event. Press any of the cursor keys results in two keydown events followed by two keyup events.....
Does anybody know why doesn't onkeypress catch up/down arrow keys while it catches left/right arrows? My only supposition is that up/ down keys are used for moving between form elements, anyway does anybody know any solution to this problem?
I'm trying to figure out how to select a value from a list that is filled dynamically using ajax auto suggest Take a look at the small code: when typing in a name by the keyboard this function is called:
I have a little problem that i hope can be solved. You start to type in an <input> field and a list of results show based on what you type, I have a list of Airports in MySQL that is check for LIKE of what is typed in and the matches show that can be selected. But you can only scroll with the mouse and not the arrow keys.
Does anyone know how I may allow arrow keys as well as the mouse to select their choice?
Firstly, apologies for my terrible JavaScript knowledge! I'm getting there! I have an array that is made up of the results of a few SQL queries. The queries return the record id and an integer. I need to sort the results of the queries by the integer. I am trying to store them in an array, using the record is as the key, then sorting the array. However, when I try to get the data out of the array, it has changed the key!
E.g. Original results [10605] = 141 [10744] = 116 [18835] = 166 [15304] = 166
Disable Arrow Keys I am creating an online flash gaming site, Aaron's Game Zone: [URL]Some of the games on it use the arrow keys, however IE also uses them to scroll the page. I am learning JavaScript and am trying to write some script to pervent the page scrolling up and down while playing a game.For example.Guardian Rock uses the arrow keys to slide around, at the same time the page scrolls.[URL]
Here is the script I've tried to write to pervent the scrolling:
<script type="text/javascript"> function KeyPressHappened(e){ if (!e) e=window.event;
I was under the impression that I and object/associative array could have other objects as the keys for properties. That is, I should be able to set myObject[anotherObject] = 1. However, while this seems to work at first glance, any new object I set as a property key overwrites the first one.Here is the result of me testing in my Chrome console:
> var obj1 = new Object(); > var obj1.someProperty = "test" "test"
How to use the shortcut keys in jvascript? Any illustration with an example? Such as suppose on clicking the Ctrl+alt key, I want to display a prompt dialog box........How to do this?
What I need is something as such (based on previous thread): I have a textfield and I want to limit the input to only numbers, letters and caps.
So the code is: <input onkeydown="return testChars(event)" type="text" .../> function testChars(e){ var keyCode = e.keyCode; if(e.shiftKey && keyCode==53){ return false; } //block "%" //HERE BLOCK EVERYTHING THATS NOT a Letter, caps and numbers if ( (keyCode > 64 && keyCode < 91) ||(keyCode > 96 && keyCode < 123) )//Letters and Caps{ return true; }else if ( keyCode > 47 && keyCode < 58 )//numbers{ return true; }}
The problem however using the onkeydown is that I would need to cater for every single possibility of them using SHIFT+1=*, SHIFT+2, SHIFT+3 etc. which would take forever. And I cant block Shift because they might use it for capitalizing letters.
I want a hash table where DOM nodes are the keys. In Rhino, I can just use the node objects directly as the keys, since the Java objects that implement the DOM have handy toString() methods that return a unique string for each object:
var a = {}; a[document] = ...; a[document.documentElement] = ...;
This is obviously not portable. The portable solution, I guess, is to come up with a hash function that works usefully on DOM nodes. Has anyone thought about this problem and come up with a solution? With a DOM 3 implementation I could even do something like:
var nodes = []; var nextIndex = 1; function getIndex(n) { var i = n.getUserData("NodeIndex"); if (!i) { i = nextIndex++; n.setUserData("NodeIndex", i, null); } return i; }
I am passing some equity option contract data from my PHP processing page to the UI. I am attempting to use the JSON response to populate a matrix. Along the far right column are the strike prices (22, 23, 24, 25, 26, etc) and along the top row are the expiration dates (Jun 2008, Jul 2008, Aug 2008, etc.). My struggle is how to match the option data to the correct strike and expiration date. An example of the JSON response is below:
Can someone help me get started on some browser-independent code for moving an image with the arrow keys? That is, if I press the up arrow, the image will move 10 pixels up; if I press the left arrow, the image will move 10 px left.
I'm wondering how to trigger something when the up,down,left,right directional keys are pressed. Lets say for now, if you press those keys, an alert comes up.
Given a JavaScript "array" (ok, so really they are "objects" but it's being treated as an array...) in the format
HTML Code: var patient_code = "0" var header_id = "1"; var question_id = "1000"; fake_data_array["patients"][patient_code][header_id][question_id] HTML Code: var fake_data_array = new Array(); fake_data_array["heading_information"] = new Array(); [Code]...
What's happening is, '1000', '1001', '1003', '1004' are being cast as integers, not strings, and it's "filling in" the first ~999 keys as 'undefined' so the length is returning something like 1005, not 7. I'm manually writing the arrays now, and will eventually be building this massive js array from a collection of existing PHP arrays. Is there a way to forcibly cast the values as strings?
I would like to have an array and define which element goes to what key. Something like this: Code: var test = [][]; test[0][0] = "foo"; test[0][1] = "bar";
However I am wondering if its possible to write it in one statement? Something like this: Code: var test[0] = [ [0] => "foo", [1] => "bar" ]; The code up doesn't work of course.
I'm using the below to limit the input into a text box to just letters, numbers, hyphens and full stops, but I also need to allow the backspace, delete and arrow keys to come through. How can I do this?
<script language="JavaScript" type="text/javascript"> <!-- function onKeyPressBlockNumbers(e) { var key = window.event ? e.keyCode : e.which; var keychar = String.fromCharCode(key); reg = /^[.a-zA-Z0-9_-]*$/; return reg.test(keychar); } //--> </script>
jsonObj={ key1: 'value for key1', nextKey: 'nextKey value', lastKey: 'value for the last Key' };
without knowing the structure of this object... is there a way to return the name of the keys?if it was a nested aray.. each key:value pair being a 2 element array I could do something like this:
var key = jsonObj[1][0]; // this would return 'nextKey'
Is there some way to determine the names of the keys ina json object, as if it was an associative array?