keyup

listen to 'CTRL+N' with javascript

旧巷老猫 提交于 2021-01-05 07:14:49
问题 I am trying to bind the 'CTRL+N' key combination, like this: var ctrlPressed = false; var nCode = 78; var ctrlCode = 224; var cmdCode = 17; document.addEventListener ("keydown", function(e){ if( e.keyCode == ctrlCode || e.keyCode == cmdCode){ ctrlPressed = true; }else{ ctrlPressed = false; } console.log(e.keyCode); }); document.addEventListener ("keyup", function(e){ if(ctrlPressed && e.keyCode == nCode){ e.preventDefault(); nou_element(parent); return; } }); Please note: jQuery isn't

On Key `Enter` trigger click event on active list item Angular

浪子不回头ぞ 提交于 2020-02-07 02:33:07
问题 I made a horizontal scroll with resources in it. I'm using the arrow key to navigate in the list, now I want to open that particular highlight list by clicking enter. Component.ts arrowkeyLocation = 0; @HostListener('document:keydown', ['$event']) keyDown(event: KeyboardEvent, resource): void { if (event.keyCode === 37 && this.arrowkeyLocation > 0) { this.arrowkeyLocation--; } if (event.keyCode === 39 && this.arrowkeyLocation < this.searchData.toArray().length - 1 ) { this.arrowkeyLocation++;

call function of other component on event in one component in Angular 6

天大地大妈咪最大 提交于 2020-01-25 10:42:46
问题 I'm using Angular 6 . I have a component HeaderComponent whose html contain an input field like header.component.html <form> <input (keyup)="search($event)"> </form> <app-search-result-card *ngIf="searchQuery.length > 3" [searchQuery]="searchQuery"> </app-search-result-card> SearchResultComponent has a function to perform search export class SearchResultCardComponent implements OnInit { @Input() searchQuery: string; searching = true; constructor( private searchService: SearchService ) { }

Set input value from current input textfield on change event

戏子无情 提交于 2020-01-24 09:56:45
问题 I have a table with two input boxes. A and B. I enter something into input A (and also B) and I want it's value to automatically be set to whatever I type into it on change event. Is this easy to do? <tr> <td><input type="text" id="A1" name="A" value=""></td> <td><input type="text" id="B1" name="B" value=""></td> </tr> 回答1: Description If you want to keep the two input elements in sync on every keystroke you should use jQuery´s .keyup() and .change() (for copy and paste) method. Sample $("#A1

'Alt' keyup event don't work on Firefox

两盒软妹~` 提交于 2020-01-17 04:13:22
问题 i try to capture this key : alt+arrow down, alt+arrow up. First, i capture alt key down : var isAlt = false; $(document).keydown(function (e) { if(e.which == 18){isAlt=true;} }).keyup(function (e) { if(e.which == 18){isAlt=false;} }); this code is ok, and alt keyup is detected. But, if i add arrow key down, when arrow keydown, it's ok, but after alt keyup is not detected : var isAlt = false; $(document).keydown(function (e) { if(e.which == 18){isAlt=true;}else{ if(e.which == 38 && isAlt ==

Using .keyup function to filter auto complete

南楼画角 提交于 2020-01-16 12:06:48
问题 Am using .keyup to filter my auto complete. However it only allows me to enter the first digit. so if my data is "Apple" when i type A - it shows Apple but i cannot type "AP" as the "P" disappears. I was expecting that i can write the whole word rather than the first letter. Code: <input id="ac" /> <span></span> var validOptions = "@Url.Action("SerialProdNumStockSiteAutoComplete", "Ajax")?stocksitenum=LW&model=" + $("#Form_Prod_Num").val(); previousValue = ""; $('#ac').autocomplete({

Using .keyup function to filter auto complete

倖福魔咒の 提交于 2020-01-16 12:04:43
问题 Am using .keyup to filter my auto complete. However it only allows me to enter the first digit. so if my data is "Apple" when i type A - it shows Apple but i cannot type "AP" as the "P" disappears. I was expecting that i can write the whole word rather than the first letter. Code: <input id="ac" /> <span></span> var validOptions = "@Url.Action("SerialProdNumStockSiteAutoComplete", "Ajax")?stocksitenum=LW&model=" + $("#Form_Prod_Num").val(); previousValue = ""; $('#ac').autocomplete({

Pygame Keyup/Keydown

痴心易碎 提交于 2020-01-14 04:12:08
问题 I'm making a little Mario for my school's Computer Club. (well, as part of a team.) Anyway, I'm having some trouble with the "keyup/keydown" commands. Here's my code: # 1 - Import library import pygame from pygame.locals import * # 2 - Initialize the game pygame.init() width, height = 1280, 1000 screen=pygame.display.set_mode((width, height)) keys = [False, False, False, False] playerpos=[100,100] # 3 - Load images player = pygame.image.load("images/totallynotgodzilla.png") # 3.1 - Load Audio

Displaying input value without a submit button to another page using javascript

坚强是说给别人听的谎言 提交于 2020-01-04 05:47:18
问题 I am trying to display the result of an input value to another page. But this input does not have a submit button. Thus, I am using keyup to store the input data. I have 2 pages, index1.php and index2.php index1.php: <form> <input type="text" name="nameValidation" id="nameValidation" placeholder="Name"> </form> <div id="display"></div> <script> $(function() { $('#nameValidation').keyup(function() { var nameValisession = $('#display').text($(this).val()); sessionStorage.setItem(

jQuery keyup function doesnt work?

时光毁灭记忆、已成空白 提交于 2019-12-30 08:57:10
问题 My HTML file: <html> <head> <script type="text/javascript" src="js/jquery-1.10.2.min.js"></script> <script type="text/javascript" src="js/scripts.js"></script> <link rel="stylesheet" type="text/css" href="style.css" /> <title> Login </title> </head> <body> <div class=loginForm> <p>Worker-ID:<input type=text id=workerID name=workerID /></p> <p>Password:<input type=password id=workerPassword name=workerPassword /></p> <input type=submit id=submitLogin name=submitLogin value="Log in"/> </div> <