Associating Keys To A Function
Jul 24, 2005I wonder if I can associate some keys (e.g. 'Ctrl+T') to some function I create with JavaScript on my webpage.
View 2 RepliesI wonder if I can associate some keys (e.g. 'Ctrl+T') to some function I create with JavaScript on my webpage.
View 2 RepliesI am trying to setup a textbox to only accept specific keys. The problem is, some of the Function keys are reading as the same values as letters.Ex.
112 - F1 - p
113 - F2 - q
114 - F3 - r[code]....
Is there another way to allow the function keys without enabling all matching letters as well?
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.
View 2 Replies View Relatedin asp.net i have a grid using up/down arrow keys when the cursor moves over the grid i need to get the values of that row where the cursor is
at present i am using window load function
window.onload = function ()
{
[code]....
same way how do i do it for up/down arrow keys
I want to build a table that knows where it has been clicked. I found the
following solution myself. Are there better ones?
http://www.student.oulu.fi/~pkarjala/question1.html
(tested on Mozilla 1.7.8/Linux)
It sets the event handlers for each TD in the build() loop, including a
parameter in the function call that is different for each TD.
The whole thing is a simple example with a table with 5 by 5 cells. If you
click on a cell it's supposed to change color. Naturally, my question is
one more general terms. How to make big tables that associate various
event handlers with various cells, and where you will know exactly which
element triggered the event? How to make it simple and maintainable?
I am attempting to provide the user with an estimated price value given their input in 2 form fields.
One is a dropdown and the other is a radio button set. They will output to a text box
I was able to achieve the desired result using integers as the text box options. However, when i replaced them with strings, the calculations no longer work (obviously )
My problem are:
1. Associating integer values with the word items listed in the dropdown. Example: "standard" should have a value of 100, "deluxe" =200 etc...
2. actually getting the calculation to complete using both dropdown and radio button elements. I'm not sure what logic to use to get it to total out. I essentially want the selected plan flat rate cost ($100 for "standard", $200 for "deluxe")to be added to the additional units cost ($50*number of units selected)
Refer to the reference URL for my intended layout and functionality [url]
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:
[Code]...
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?
I want to block alt+f4 key using javascipt. Please give some example.
View 1 Replies View RelatedFirstly, 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
[Code]...
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;
[code]....
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"
[code]....
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?
View 3 Replies View RelatedWhat 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 want this to work with DOM 2 as well, though.
Any ideas?
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:
Code:
{"calls":
[
{"row_id":119,"type":"call","expiration":"JUN 20, 2009","t1":22,"strike":"25.00","symbol":"JSAFE"},
{"row_id":127,"type":"call","expiration":"JUN 20, 2009","t1":22,"strike":"26.00","symbol":"JSAFI"},
[code]....
Would be a JSON returned object that has all the option prices for all the expirations as properties.
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.
View 6 Replies View RelatedI'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.
View 14 Replies View RelatedGiven 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>
<form>
<input type="text" onkeypress="return onKeyPressBlockNumbers(event);" />
</form>
With this JSON object as an example:
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?
Im trying to learn how to scroll using arrow keys or hotkeys. Where you're able to use your arrow keys to move side to side and up and down.
Here are the 2 best examples of how it functions:
thinkingforaliving[dot]org/archives/4580
ffffound[dot]com (top right says hotkeys to scroll with)
Can anyone link me to how to script that? Or even if there's a proper term I should know about to search for tutorials..
I am trying to assign the left and right arrows, but I cannot get the code to work. It would be great to get some help--I am a newbie to coding.
[Code]...