[Angular HTML] Overwrite input value, String.fromCharCode & input.selectionStart
@HostListener('keydown', ['$event', '$event.keyCode'])
onKeyDown($event: KeyboardEvent, keyCode) {
if(keyCode !== TAB) {
$event.preventDefault();
}
// get value for the key
const val = String.fromCharCode(keyCode);
// get position
const cursorPos = this.input.selectionStart;
overWriteCharAtPosition(this.input, val, cursorPos);
}
export const overWriteCharAtPosition = (
input: HTMLInputElement,
val: any,
position: number
) => {
const currentValue = input.value;
input.value = currentValue.slice(, position) + val + currentValue.slice(position+);
};
[Angular HTML] Overwrite input value, String.fromCharCode & input.selectionStart的更多相关文章
- Android input输入框 移动页面input手机键盘中的“搜索”按键
动页面input手机键盘中的“搜索”按键 满足以下几点机即可: input type="search" 放到form标签中 使用action属性 <form ac ...
- 封装input 逐渐,且input插件必须带有默认值。
封装input 逐渐,且input插件必须带有默认值. 组件: <template> <div class="input-show"> <span c ...
- 数组乘积--满足result[i] = input数组中除了input[i]之外所有数的乘积(假设不会溢出
数组乘积(15分) 输入:一个长度为n的整数数组input 输出:一个长度为n的整数数组result,满足result[i] = input数组中除了input[i]之外所有数的乘积(假设不会溢出). ...
- Oracle delete input与delete all input
oracle官方文档提示:If you had specified DELETE INPUT rather than DELETE ALL INPUT, then RMAN would have on ...
- input type类型和input表单属性
一.input type类型 1.Input 类型 - email 在提交表单时,会自动验证 email 域的值. E-mail: <input type="email" n ...
- 定制 input[type="radio"] 和 input[type="checkbox"] 样式
表单中,经常会使用到单选按钮和复选框,但是,input[type="radio"] 和 input[type="checkbox"] 的默认样式在不同的浏览器或 ...
- 修改 input[type="radio"] 和 input[type="checkbox"] 的默认样式
表单中,经常会使用到单选按钮和复选框,但是,input[type="radio"] 和 input[type="checkbox"] 的默认样式在不同的浏览器或 ...
- angular自定义指令解决IE89不支持input的placeholder属性
下面代码实测通过,直接copy到本地运行即可. <!DOCTYPE html> <html> <head> <meta charset="UTF-8 ...
- How to Construct the Input Bet String
The purpose of this section is to describe the format of the string which will submitted to the Pyth ...
随机推荐
- 求s=a+aa+aaa+aaaa+aa...a的值,其中a是一个数字。 例如2+22+222+2222+22222(此时共有5个数相加),几个数相加有键盘控制。
代码: package com.liron.p1; import java.io.IOException; import java.util.Scanner; /** * 求s=a+aa+aaa+aa ...
- Django项目之Web端电商网站的实战开发(三)
说明:该篇博客是博主一字一码编写的,实属不易,请尊重原创,谢谢大家! 接着上一篇博客继续往下写 :https://blog.csdn.net/qq_41782425/article/details/8 ...
- RecyclerView下拉刷新和载入很多其它
之前一直写的是ListVIew下拉刷新,可是好多朋友都说要RecycleView的下拉刷新和滑动载入.事实上,这个原理都是几乎相同.抽出时间,我就写了下RecycleView的下拉刷新和滑动载入很多其 ...
- C# 读取指定文件夹中的全部文件,并按规则生成SQL语句!
本实例的目的在于: 1 了解怎样遍历指定文件夹中的全部文件 2 控制台怎样输入和输出数据 代码: using System; using System.IO; namespace ToSql{ cla ...
- ip地址个数的计算
一个IP地址,却关联太多的知识 二进制与 8 比特 电脑中显示出来的数字是 10 进制的,键盘的每一个键都由一个 8 位的二进制编码,所以 1 字节等于 8 比特.对数字而言,1 的二进制是 0000 ...
- 23. Node.Js Buffer类(缓冲区)-(三)文件读取实例
转自:https://blog.csdn.net/u011127019/article/details/52513109
- Office2010激活工具
mini-KMS Activator是一款好用Office2010激活工具,“KMS”是微软对于“大客户”(VOL或VL)提供的Microsoft产品激活方式之一.在适用此方式的Microsoft产品 ...
- 【Codeforces Round #451 (Div. 2) A】Rounding
[链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 模拟 [代码] /* 1.Shoud it use long long ? 2.Have you ever test several ...
- APM2.8 Rover 自己主动巡航车设计(固件安装和设置)
1.2 APM2.8软件安装与固件下载 下载Mission Planner这个地面基站软件,这里介绍的是windoews平台下的,在MAC或者linux下能够使用QGroundCont基于QT编写的地 ...
- [Javascript AST] 0. Introduction: Write a simple BabelJS plugin
To write a simple Babel plugin, we can use http://astexplorer.net/ to help us. The plugin we want to ...